Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

shell script get arguments

$ myscript.sh first_arg second_arg

# myscript.sh
#!/bin/bash
echo $1 # output: first_arg
echo $2 # output: second_arg
Comment

bash parameter

# 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

PREVIOUS NEXT
Code Example
Shell :: check user shell in linux 
Shell :: install docker desktop on server 2019 
Shell :: git reset initial commit 
Shell :: how to run power shell script 
Shell :: How to create or generate secret key for django 
Shell :: how to create folder in github 
Shell :: git delete remote branch 
Shell :: wsl2 settings 
Shell :: bash: conda: command not found 
Shell :: linux check ssh connections 
Shell :: revert local merge 
Shell :: git change file case windows 
Shell :: undo git commit and keep changes 
Shell :: cp command exclude files 
Shell :: td-agent restart 
Shell :: ssh key generation 
Shell :: pm2 process disappears after reboot 
Shell :: Installing Apache Tomcat on MacOS Mojave using Homebrew 
Shell :: nuxt new project npm 
Shell :: install portainer on raspberry pi 
Shell :: powershell get arguments 
Shell :: how do you merge two git repositories 
Shell :: configure static ip address linux 
Shell :: ubuntu uninstall ros 
Shell :: linux bash connect to postgres 
Shell :: docker-compose logs path 
Shell :: ignore file git 
Shell :: git remove tag from remote 
Shell :: Unsupported upgrade request. 
Shell :: find name file in cmd 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =