Cat
cat 명령어는 텍스트파일 내용을 출력하거나 두 개 이상의 파일을 연결하여 출력할 수 있다.
Example
각 행에 번호를 붙여서 출력:
빈 행에도 번호를 붙임:
연속되는 2개이상의 빈 행을 한행으로 출력:
Assign multi-line string
Examples of cat <<EOF
syntax usage in Bash. 참고로 이러한 방법을 Here document라고 한다. 자세한 내용은 해당 항목 참조.
Assign multi-line string to a shell variable
The $sql
variable now holds the new-line characters too. You can verify with echo -e "$sql"
Pass multi-line string to a file in Bash
The print.sh
file now contains:
Pass multi-line string to a pipe in Bash
The b.txt
file contains bar and baz lines. The same output is printed to stdout.
환경변수 치환을 막고 싶다면
다음과 같이 사용하면 $temp
가 환경변수로 치환된다.
이 현상을 막으려면 EOF
를 작은 따옴표로 쿼우팅('EOF'
) 해야 한다.