Your Location is: Home > Linux

Linux bash get an input on the same line as execution? [duplicate]

From: Iran View: 2693 throwaway 


I made a .sh file with a program, the current input is as follows:

$ ./

How can I make it so the input is as follows instead:

$ ./ file.txt

Best answer

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.