0

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
Mureinik
  • 297,002
  • 52
  • 306
  • 350
throwaway
  • 55
  • 5
  • Is this string 'file.txt' produced by your script? It it the output of your script? If so then i'm afraid the desired output is imposible, – Ivan Feb 11 '21 at 10:58

1 Answers1

1

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.

Mureinik
  • 297,002
  • 52
  • 306
  • 350