IT How Tos

Home

About

Sitemap

Contact

How to take the second parameter onwards in BASH

BASH Script File

  • In order to take pass the first parameter in BASH
    for one item and then the second parameters onwards as something else,
    this can be done in a BASH script as follows:
#!/bin/bash

first=$1
rest="${@:2}"
echo first - $first
echo rest - $rest

Output

  • The output from running the above command
./script 1 2 3 4 5 6 7 8
first - 1
rest - 2 3 4 5 6 7 8