Languages
[Edit]
EN

Bash - omit first argument from command line

3 points
Created by:
Maryamcc
511

In this article, we would like to show you how to omit first argument from command line in Bash.

Practical example

Edit

In this example, we use "${@:2}" to capture all arguments passed from command line starting from the second argument. Then we iterate through all parameters using for loop and print them using echo command.

Example script.sh file:

Run in the command line:

Output:

 

See also

Edit
  1. Bash - capture all arguments passed from command line (regardless of their number)

Alternative titles

  1. Bash - skip the first argument from command line
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join