일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- mysql
- ngui
- dataframe
- List
- awk
- expect
- pandas
- Shader
- DROP
- FIND
- Unity
- if
- conda
- boost
- ubuntu
- C++
- 쉘
- autovacuum
- 배열
- SSH
- sql
- pi
- Eclipse
- null
- with
- python
- sqlite
- postgresql
- SVN
- c++11
- Today
- Total
その先にあるもの…
[LINUX] 리다이렉션(Redirection), 파이프(Linux Pipe), CAT 본문
리다이렉션(Redirection)
< , >를 사용하여 표준 스트림의 방향을 바꿔준다. (글자들을 꺽쇠 방향으로 보낸다고 생각하면 된다)
ls > list.txt
ls 명령어의 결과를 list.txt파일에 덮어 씌운다.
ls >> list.txt
ls 명령어의 결과를 list.txt파일 끝에 붙인다.
head < list.txt
head 명령어에 list.txt파일 내용을 밀어 넣는다.
head < list.txt > list2.txt
head명령어에 list.txt를 밀어넣고 나서 출력된 결과를 list2.txt에 밀어 넣는다.(list2.txt는 없어도 생성된다)
파이프( Linux Pipe)
리다이렉셔은 파일간에서 사용된다면 파이프( | )는 프로세스(명령어, 실행파일)간에 사용된다.
ls | grep ls.txt
ls의 출력 스트림에서 grep의 입력 스트림으로 받아 ls.txt를 찾는다.
cat
파일 내용을 display해준다.
cat list.txt
list.txt 를 화면에 보여준다.
cat list.txt list2.txt
list.txt list2.txt를 연속으로 화면에 출력해 준다.
cat -b list.txt
행 번호를 붙임
cat -n list.txt
빈행에도 번호를 붙임
cat -s list.txt
연속된 2개 이상의 빈 행을 1행으로 바꿈
CAT과 <를 이용해 파일 생성하기
cat < text.txt
1
2
3
ctrl+D (입력상태에서 빠져나온다)
text.txt에 1,2,3이 저장되어 있다.
dump.log에 "error"만 찾아 파일에 입력하기
cat dump.log | grep "error" > error.txt
'컴퓨터 사용' 카테고리의 다른 글
gnome-connection_manager (0) | 2019.01.18 |
---|---|
[LINUX] 프로세스명으로 KILL (0) | 2018.12.12 |
[android] Emulator: emulator: ERROR: x86 emulation currently requires hardware acceleration! 해결 (0) | 2018.11.20 |
[C++] 0xc000007b Error Solution (0) | 2018.09.05 |
[LINUX] cherrymusic (0) | 2018.08.30 |