I made a .sh file with a program, the current input is as follows:
$ ./myprogram.sh
file.txt
How can I make it so the input is as follows instead:
$ ./myprogram.sh file.txt
I made a .sh file with a program, the current input is as follows:
$ ./myprogram.sh
file.txt
How can I make it so the input is as follows instead:
$ ./myprogram.sh file.txt
Inside the shell script, you can refer to the arguments by their positions as $1
, $2
, etc. Note that the arguments start at 1, and $0
is the name of the executed script. $#
contains the total number of arguments.