1

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
1
  • 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, Commented Feb 11, 2021 at 10:58

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.