Bash script that runs a command with arguments and redirects

cpd1

So I'm trying to execute a command in a bash script multiple times with different but same number of arguments while redirecting the output to a text file. For example ...

./test arg1 arg2 arg3 >> output.txt

This works if I do it at the command line. In a script where I have...

command ./test 10 5 option1 >> output.txt


command ./test 5 10 option2 >> output.txt

And run the script, I get command not found. If I remove the redirect to ouput.txt, the script then works / prints to the terminal window

I tried searching online but I could not find examples where arguments were used which then redirected

Anyone able to help?

cpd1

The issue had to do with writing the script in Windows in Sublime Text and then transferring it to a Linux server. Switching the mode in Sublime Text made the difference

Videonauth also pointed out that I should have just one redirect symbol ">" since for the first line since it is a new file

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Running a command in a new terminal instance in a bash script

分類Dev

Bash script to monitor file change and execute command

分類Dev

Propagate all arguments in a bash shell script

分類Dev

Parse command line arguments in a Ruby script

分類Dev

Java command with flags runs in bash but not zsh

分類Dev

Java command with flags runs in bash but not zsh

分類Dev

Combine sed commands into one command in bash script

分類Dev

Multiple Fortran arguments in bash script

分類Dev

How to execute a command within a bash script?

分類Dev

Linux Bash Script, Single Command But Multiple Lines?

分類Dev

exit a bash command in a script without exiting the script

分類Dev

Bash Script - check arguments - files in for

分類Dev

Java command line arguments through shell script

分類Dev

Passing command line arguments through Bash

分類Dev

Execute sed command in a bash script

分類Dev

Shell script wrapper to prevent running command with no arguments?

分類Dev

bash execute command for X arguments at a time

分類Dev

Bash : command line with optional arguments

分類Dev

Using bash variables in perl command in bash script

分類Dev

how to loop through arguments in a bash script

分類Dev

Bash script using mysql command with variables failing

分類Dev

bash: Why are () causing error in script but not on the command line?

分類Dev

How to turn Diff command into bash script with prompt

分類Dev

Bash script - unix - command not found

分類Dev

bash script to check website content by curl command

分類Dev

Bash script can't find command if quoted

分類Dev

Simplest way to "forward" script arguments to another command

分類Dev

Command works in terminal but not in bash script

分類Dev

How to run bash command with arguments at scheduled time

Related 関連記事

  1. 1

    Running a command in a new terminal instance in a bash script

  2. 2

    Bash script to monitor file change and execute command

  3. 3

    Propagate all arguments in a bash shell script

  4. 4

    Parse command line arguments in a Ruby script

  5. 5

    Java command with flags runs in bash but not zsh

  6. 6

    Java command with flags runs in bash but not zsh

  7. 7

    Combine sed commands into one command in bash script

  8. 8

    Multiple Fortran arguments in bash script

  9. 9

    How to execute a command within a bash script?

  10. 10

    Linux Bash Script, Single Command But Multiple Lines?

  11. 11

    exit a bash command in a script without exiting the script

  12. 12

    Bash Script - check arguments - files in for

  13. 13

    Java command line arguments through shell script

  14. 14

    Passing command line arguments through Bash

  15. 15

    Execute sed command in a bash script

  16. 16

    Shell script wrapper to prevent running command with no arguments?

  17. 17

    bash execute command for X arguments at a time

  18. 18

    Bash : command line with optional arguments

  19. 19

    Using bash variables in perl command in bash script

  20. 20

    how to loop through arguments in a bash script

  21. 21

    Bash script using mysql command with variables failing

  22. 22

    bash: Why are () causing error in script but not on the command line?

  23. 23

    How to turn Diff command into bash script with prompt

  24. 24

    Bash script - unix - command not found

  25. 25

    bash script to check website content by curl command

  26. 26

    Bash script can't find command if quoted

  27. 27

    Simplest way to "forward" script arguments to another command

  28. 28

    Command works in terminal but not in bash script

  29. 29

    How to run bash command with arguments at scheduled time

ホットタグ

アーカイブ