리눅스의 PS1은 현재 쉘의 앞부분을 출력할 때 유용하게 사용할 수 있다.
[~] echo :$PS1:
:[\w]\[\033[00m\] :
$ PS1=" \"$PWD\" "
"/Users/samuel.kim"
"/Users/samuel.kim" PS1="$ "
$
$ PS1="명령 내려주세요 $ "
명령 내려주세요 $
명령 내려주세요 $
$ PS1="\H $ "
google-MacBook-Air-100.local $
google-MacBook-Air-100.local $
리눅스의 PS2는 멀티 커맨드 라인에 사용되는 문자로 사용된다.
$ echo :$PS2:
:> :
$ for x in 10 20 30
> do
> echo $x
> done
10
20
30
$ for x in 10 20 30
do
echo $x
done
10
20
30
자세한 내용은 man bash의 prompting 섹션에 설명되어 있다.
$ man bash
PROMPTING
When executing interactively, bash displays the primary prompt PS1
when it is ready to read a command, and the secondary prompt PS2
when it needs more input to complete a command. Bash allows these
prompt strings to be customized by inserting a number of backslash-
escaped special characters that are decoded as follows:
\a an ASCII bell character (07)
\d the date in "Weekday Month Date" format (e.g., "Tue
May 26")
\D{format}
the format is passed to strftime(3) and the result is
inserted into the prompt string; an empty format
results in a locale-specific time representation.
The braces are required
\e an ASCII escape character (033)
\h the hostname up to the first `.'
\H the hostname
\j the number of jobs currently managed by the shell
\l the basename of the shell's terminal device name
\n newline
\r carriage return
\s the name of the shell, the basename of $0 (the por-
tion following the final slash)
\t the current time in 24-hour HH:MM:SS format
\T the current time in 12-hour HH:MM:SS format
\@ the current time in 12-hour am/pm format
\A the current time in 24-hour HH:MM format
\u the username of the current user
\v the version of bash (e.g., 2.00)
'unix and linux' 카테고리의 다른 글
[shell] 중괄호와 널에 대한 기본 문자열 (0) | 2017.02.02 |
---|---|
export -p (0) | 2017.01.31 |
echo 이스케이프 - \c (0) | 2017.01.23 |
echo 와 >& 팁 (0) | 2017.01.19 |
네트워크 카드의 네트워크 트래픽 확인하기 - iftop (0) | 2017.01.19 |