shell

How do I use the output of an ls command in an if statement in a bash shell [duplicate]

为君一笑 提交于 2021-02-09 07:08:26
问题 This question already has answers here : Test whether a glob has any matches in bash (20 answers) Closed 6 months ago . I want to check if only one instance of a file exists before going on to process that file. I can check how many instances exist using this command: ls -l $INPUT_DIR/${INPUT_FILE_PREFIX}cons*.csv.gz | wc -l; However, when I go to use this within an if statement, I am warned that the ls: command not found . if [ls -l $INPUT_DIR/${INPUT_FILE_PREFIX}cons*.csv.gz | wc -l = '1']

why questionmark comes in the end of filename when i create .txt file through shell script? [duplicate]

孤者浪人 提交于 2021-02-09 05:52:09
问题 This question already has answers here : Shell Scripting unwanted '?' character at the end of file name (2 answers) Closed 4 years ago . I am writing one shell script in which I am supposed to create 1 text file. When I do this, a question mark comes at the end of file name. what is the reason? I am trying below methods in bash script. 1) grep ERROR a1* > text.txt 2) touch text.txt In both the methods, instead of text.txt , there is a file generated as text.txt? what should I do to overcome

why questionmark comes in the end of filename when i create .txt file through shell script? [duplicate]

流过昼夜 提交于 2021-02-09 05:52:01
问题 This question already has answers here : Shell Scripting unwanted '?' character at the end of file name (2 answers) Closed 4 years ago . I am writing one shell script in which I am supposed to create 1 text file. When I do this, a question mark comes at the end of file name. what is the reason? I am trying below methods in bash script. 1) grep ERROR a1* > text.txt 2) touch text.txt In both the methods, instead of text.txt , there is a file generated as text.txt? what should I do to overcome

GitHub Actions workflow error: Run Command Timeout! Even if the script did well

◇◆丶佛笑我妖孽 提交于 2021-02-09 01:44:16
问题 I want to deploy my Nuxt.js application on my remote server each time I commit into repository. Here is my deploy.yml: name: 'Deployment' on: push: branches: ['master'] jobs: deploy: name: Deploy runs-on: ubuntu-latest steps: - name: Connect to SSH uses: appleboy/ssh-action@master with: host: webhostgb.com username: root key: ${{ secrets.PRIVATE_KEY }} port: 22 script: | cd whgb-new git pull origin master npm run build fuser -kn tcp 3000 pm2 restart deploy.sh Basically deploy.sh runs npm

GitHub Actions workflow error: Run Command Timeout! Even if the script did well

梦想与她 提交于 2021-02-09 01:41:57
问题 I want to deploy my Nuxt.js application on my remote server each time I commit into repository. Here is my deploy.yml: name: 'Deployment' on: push: branches: ['master'] jobs: deploy: name: Deploy runs-on: ubuntu-latest steps: - name: Connect to SSH uses: appleboy/ssh-action@master with: host: webhostgb.com username: root key: ${{ secrets.PRIVATE_KEY }} port: 22 script: | cd whgb-new git pull origin master npm run build fuser -kn tcp 3000 pm2 restart deploy.sh Basically deploy.sh runs npm

Cron xdotool doesn't run

别来无恙 提交于 2021-02-08 21:54:34
问题 I am new to using crontab, and I've been trying to get a simple cron job. I want press F5 every 1 minute to refresh Mozzila Firefox. I am using xdotool for press F5. I have script /usr/local/bin/refresh.sh: #!/bin/bash xdotool search --name "Mozilla Firefox" key F5 If i run it in command line it works fine. And permission: -rwxr-xr-x. 1 root root 89 15. čec 10.32 refresh.sh In crontab i have: */1 * * * * cd /usr/local/bin && sh refresh.sh But script run by cron doesnt work. Can anyone tell me

Cron xdotool doesn't run

泄露秘密 提交于 2021-02-08 21:53:40
问题 I am new to using crontab, and I've been trying to get a simple cron job. I want press F5 every 1 minute to refresh Mozzila Firefox. I am using xdotool for press F5. I have script /usr/local/bin/refresh.sh: #!/bin/bash xdotool search --name "Mozilla Firefox" key F5 If i run it in command line it works fine. And permission: -rwxr-xr-x. 1 root root 89 15. čec 10.32 refresh.sh In crontab i have: */1 * * * * cd /usr/local/bin && sh refresh.sh But script run by cron doesnt work. Can anyone tell me

Cron xdotool doesn't run

大城市里の小女人 提交于 2021-02-08 21:52:49
问题 I am new to using crontab, and I've been trying to get a simple cron job. I want press F5 every 1 minute to refresh Mozzila Firefox. I am using xdotool for press F5. I have script /usr/local/bin/refresh.sh: #!/bin/bash xdotool search --name "Mozilla Firefox" key F5 If i run it in command line it works fine. And permission: -rwxr-xr-x. 1 root root 89 15. čec 10.32 refresh.sh In crontab i have: */1 * * * * cd /usr/local/bin && sh refresh.sh But script run by cron doesnt work. Can anyone tell me

How to run mongorestore after mongod in docker

青春壹個敷衍的年華 提交于 2021-02-08 20:54:06
问题 I'm trying to set up a mongodb-server with docker, let it download a dump from the web and populate it with that info. My problem is that I can make it run and fill the database, but after it's done that, it just closes. This was how I went about solving my problem: sudo -u mongodb /usr/bin/mongod --config $conf $args & mongorestore dump The problem here is that I can't run mongorestore if mongod isn't running, but if I start mongod with mongod & , then the container will close down after

Why does ((0)) cause a Bash script to exit if `set -e` directive is present?

为君一笑 提交于 2021-02-08 16:59:39
问题 This outputs before\n : #!/usr/bin/env bash set -e echo before ((0)) echo after Removing set -e or changing ((0)) to ((1)) makes the program output before\nafter\n as expected. Why does ((0)) trigger the set -e exit condition? 回答1: This will explain: ((0)) echo $? 1 ((1)) echo $? 0 So it is due to non-zero return status of arithmetic expression evaluation in (( and )) your script is exiting when set -e is being used. As help set says this: -e Exit immediately if a command exits with a non