Given the following part of a script: What is the meaning of $1?

Given the following part of a script: What is the meaning of $1?Category: Linux EssentialsGiven the following part of a script: What is the meaning of $1?
Linux Questions Staff asked 1 year ago

Given the following part of a script:

if [ -f $1 ]; then
   echo “I am here”
fi

What is the meaning of $1?

  • It is a special variable that indicates the exit code of the command before it
  • It is the first argument passed to the script
  • It is a file called $1
  • It is a parameter to –f, indicating the size of the file
  • It is a list of files that gets interpolated

About the author