Shell script special variables

Introduction

Make a note of simple special variables in shell scripts

How to use

Variable name Overview
$0 Shell script filename
$1~ Shell argument value
$# Number of shell arguments
$@ Get all arguments
$$ Shell process number

Create a file called hello

hello


#!/bin/bash

echo "hello $1"
echo "hello $2"

echo $0
echo $#
echo $@
echo $$

Pass the value takuya`` ryo.

$ ./hello takuya ryo

Execution result

hello takuya
hello ryo
./hello
2
takuya ryo
86199

Finally

I'm still studying, so I'd appreciate it if you could point out any corrections, etc. m (__) m

Recommended Posts

Shell script special variables
Shell script basics # 2
Shell variables, environment variables
Shell script command replacement
Shell script @ study memo
Let's try a shell script
[Infrastructure] Linux command, shell script collection
Automate environment construction with Shell Script
Shell script numerical calculation bc command
[Ubuntu] How to execute a shell script
Manage logrotate generations with a shell script.
Creating a shell script to write a diary