Skip to content

Instantly share code, notes, and snippets.

@hoggren
Created March 15, 2019 16:35
Show Gist options
  • Save hoggren/5f63ee9dec25b44bbcd440362fa4c886 to your computer and use it in GitHub Desktop.
Save hoggren/5f63ee9dec25b44bbcd440362fa4c886 to your computer and use it in GitHub Desktop.
Get all arguments into one array - without the application name
#!/bin/bash
# Test run: ./print-arguments.sh arg1 arg2 arg3 arg4
#
# Author: Patrik Hoggren <p@hoggren.nu>
# https://www.github.com/phoggren
ARGS=("$@");
# print ALL arguments
echo "${ARGS[*]}";
# print first argument
echo "${ARGS[0]}";
# print second argument
echo "${ARGS[1]}";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment