Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

bash scripts arguments

# bash arguments cheatsheet
$1, $2, ... -> are the positional parameters.
"$@"        -> is an array-like construct of all positional parameters, {$1, $2, $3 ...}.
"$*"        -> is the IFS expansion of all positional parameters, $1 $2 $3 ....
$#          -> is the number of positional parameters.
$-          -> current options set for the shell.
$$          -> pid of the current shell (not subshell).
$_          -> most recent parameter (or the abs path of the command to start the current shell immediately after startup).
$IFS        -> is the (input) field separator.
$?          -> is the most recent foreground pipeline exit status.
$!          -> is the PID of the most recent background command.
$0          -> is the name of the shell or shell script.
Comment

How to Pass Arguments to a Bash Script

makereport -u jsmith -p notebooks -d 10-20-2011 -f pdf

#!/bin/bash
while getopts u:d:p:f: option
do
case "${option}"
in
u) USER=${OPTARG};;
d) DATE=${OPTARG};;
p) PRODUCT=${OPTARG};;
f) FORMAT=${OPTARG};;
esac
done
Comment

PREVIOUS NEXT
Code Example
Shell :: how to watch a log file in linux 
Shell :: how to clone a specific branch from github that you are not working 
Shell :: sh increment variable 
Shell :: git fatal bad revision cherry-pick 
Shell :: create a git repository from local machine and push it online 
Shell :: how to start xammp on linux 
Shell :: upload folder with gitbash 
Shell :: command to add a user to a group 
Shell :: grep without match 
Shell :: find all .desktop files linux 
Shell :: parent branch 
Shell :: linux script to clean up log files in /var/log 
Shell :: arch linux pacman cannot install 
Shell :: enable apache2 site 
Shell :: nodejs installation on ubuntu 
Shell :: git restore file 
Shell :: how to enable gitlab runner to use local docker images 
Shell :: ubuntu kill service 
Shell :: post webhook bash 
Shell :: powershell break loop 
Shell :: git revert back to specific commit 
Shell :: chmod add execute permission to useer 
Shell :: remove gitignore files 
Shell :: git submodule push current branch to master 
Shell :: docker create image and push 
Shell :: cmd remove directory not empty windows 
Shell :: see changes git command line 
Shell :: remove yum package 
Shell :: brew check installed packages version 
Shell :: how to install wine in ubuntu 18.04 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =