본문 바로가기
프로...Linux

[sh] predefined variables(special)

by 크크다스 2018. 9. 28.
반응형

[sh] predefined variables(special)


#!/bin/sh

PID="$$"

PPID=$(cat /proc/$PID/status | grep "^PPid" | cut -f2)

PPID_cmdline=$(cat /proc/$PPID/cmdline)

PPID_comm=$(cat /proc/$PPID/comm)

echo "PPID Process> $PPID_comm[$PPID_cmdline]"


Result>
PPID Process> ash[/bin/ash--login]


출처> https://www.ibm.com/support/knowledgecenter/en/ssw_aix_71/com.ibm.aix.osdevice/bourne_shell_predefined_spec_vars.htm


ItemDescription
$@Expands the positional parameters, beginning with $1. Each parameter is separated by a space.

If you place double quotation marks (" ") around $@, the shell considers each positional parameter a separate string. If no positional parameters exist, the Bourne shell expands the statement to an unquoted null string.

$*Expands the positional parameters, beginning with $1. The shell separates each parameter with the first character of the IFS variable value.

If you place double quotation marks (" ") around $*, the shell includes the positional parameter values, in double quotation marks. Each value is separated by the first character of the IFS variable.

$#Specifies the number of positional parameters passed to the shell, not counting the name of the shell procedure itself. The $# variable thus yields the number of the highest-numbered positional parameter that is set. One of the primary uses of this variable is to check for the presence of the required number of arguments. Only positional parameters $0 through $9 are accessible through the shell.
$?Specifies the exit value of the last command executed. Its value is a decimal string. Most commands return a value of 0 to indicate successful completion. The shell itself returns the current value of the $? variable as its exit value.
$$Identifies the process number of the current process. Because process numbers are unique among all existing processes, this string is often used to generate unique names for temporary files.
The following example illustrates the recommended practice of creating temporary files in a directory used only for that purpose:
temp=/tmp/$$
ls >$temp
.
.
.
rm $tempcopy to clipboard
$!Specifies the process number of the last process run in the background using the & terminator.
$-A string consisting of the names of the execution flags currently set in the shell.


반응형

'프로...Linux' 카테고리의 다른 글

[SVN] Repository 추가 생성  (0) 2018.11.15
[sh] bourne shell(sh)에서 rand 사용법  (0) 2018.11.06
[Linux/WEB] APM 설치  (0) 2018.08.07
[Linux/SYS] 절전모드 / Hostname 등  (0) 2018.08.07
[OpenWrt] Makefile  (0) 2018.07.25