"Bash"의 두 판 사이의 차이

wwiki
이동: 둘러보기, 검색
(script syntax)
1번째 줄: 1번째 줄:
==script syntax==
+
https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html
  
===if===
+
==Shell Syntax==
<syntaxhighlight lang="bash">
+
 
 +
== Shell Commands ==
 +
 
 +
=== Reserved Words ===
 +
 
 +
=== Simple Commands ===
 +
 
 +
=== Pipelines ===
 +
 
 +
=== List of Commands ===
 +
 
 +
=== Compound Commands ===
 +
 
 +
==== Looping Constructs ====
 +
 
 +
==== Conditional Constructs ====
 +
'''if'''<syntaxhighlight lang="bash">
 
if [ -z "$1" ] && [ -z "$2" ]
 
if [ -z "$1" ] && [ -z "$2" ]
  
18번째 줄: 34번째 줄:
  
 
fi
 
fi
</syntaxhighlight>
+
</syntaxhighlight>연산자
  
==== 연산자 ====
+
<nowiki>=</nowiki>
=
 
  
 
!=
 
!=
32번째 줄: 47번째 줄:
  
 
True if the length of <var>string</var> is non-zero.
 
True if the length of <var>string</var> is non-zero.
 +
 +
==== Grouping Commands ====
 +
 +
=== Coprocesses ===
 +
 +
=== GNU Parallel ===
 +
 +
== Shell Functions ==
 +
 +
== Shell Parameters ==
 +
 +
== Shell Expansions ==
 +
 +
=== Brace Expansion ===
 +
 +
=== Tilde Expansion ===
 +
 +
=== Shell Parameter Expansion ===
 +
 +
=== 명령 대체(Command Substitution) ===
 +
다음과 같이 사용한다.<syntaxhighlight lang="bash">
 +
$(command)
 +
</syntaxhighlight>or<syntaxhighlight lang="bash">
 +
`command`
 +
</syntaxhighlight>변수에 넣어 출력할 수 있다.<syntaxhighlight lang="bash">
 +
OUTPUT=$(ls -1)
 +
echo "${OUTPUT}"
 +
</syntaxhighlight>
 +
 +
=== Arithmetic Expansion ===
 +
 +
=== Process Substitution ===
 +
 +
=== Word Splitting ===
 +
 +
=== Filename Expansion ===
 +
 +
=== Quote Removal ===
 +
 +
== Redirections ==
 +
 +
== Executing Commands ==
 +
 +
== Shell Scripts ==
 +
 +
 +
  
 
=== stdout없애기 ===
 
=== stdout없애기 ===
45번째 줄: 107번째 줄:
  
 
\": "출력해야 하는 경우
 
\": "출력해야 하는 경우
 +
  
 
==단축키==
 
==단축키==

2022년 2월 7일 (월) 14:18 판

https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html

Shell Syntax

Shell Commands

Reserved Words

Simple Commands

Pipelines

List of Commands

Compound Commands

Looping Constructs

Conditional Constructs

if

if [ -z "$1" ] && [ -z "$2" ]

then

  somecode1

elif [ "$1" = "run" ]; then

  somecode

else

  somecode2

fi

연산자

=

!=

-z string

True if the length of string is zero.

-n string

True if the length of string is non-zero.

Grouping Commands

Coprocesses

GNU Parallel

Shell Functions

Shell Parameters

Shell Expansions

Brace Expansion

Tilde Expansion

Shell Parameter Expansion

명령 대체(Command Substitution)

다음과 같이 사용한다.

$(command)

or

`command`

변수에 넣어 출력할 수 있다.

OUTPUT=$(ls -1)
echo "${OUTPUT}"

Arithmetic Expansion

Process Substitution

Word Splitting

Filename Expansion

Quote Removal

Redirections

Executing Commands

Shell Scripts

stdout없애기

>/dev/null

stderr없애기

2>/dev/null

문자열

': 작은 따옴표 안의 문자 그대로 사용

": 문자열 변수는 치환

\": "출력해야 하는 경우


단축키

이동

  • alt+b: 현재 단어의 시작으로 이동
  • alt+f: 현재 단어의 끝으로 이동

잘라내기

  • alt+d: 커서부터 오른쪽 단어 잘라내기
  • ctrl+w: 커서의 왼쪽 단어 잘라내기
  • ctrl+k: 커서부터 끝까지 잘라내기
  • ctrl+u: 처음부터 커서 앞까지 잘라내기

실행

  •  !!: 직전 명령어 실행
  •  !tail: 이전 명령어 중에 tail 로 시작했던 명령어 실행
  • ctrl+r: Recall the last command matching the characters you provide.

프롬프트

.bashrc에 PS!변수에 저장된다.

special characters: https://www.gnu.org/software/bash/manual/html_node/Controlling-the-Prompt.html#Controlling-the-Prompt

ANSI color: https://en.wikipedia.org/wiki/ANSI_escape_code#Colors

외부입력

http://www.gnu.org/software/bash/bash.html

매뉴얼: http://www.gnu.org/software/bash/manual/html_node/index.html