">" (rediretion)
">" 이러한것들을 우리는 보통 꺽쇠라한다. 그러나 리눅스에서는 ">" 를 다르게 이용한다.
물론 ">"도 여러가지 기능이 있다. "<" ">" 이렇게 방향에 따라 다른 역활을 하기도 하고
">>" 이런식으로도 쓰인다.
우선은 간단하게 ">" 와 ">>"를 써보자
[root@dangerzo dangerzo]# ls
abab good grep.txt want_3 want_4 want_5 want_6 wanted_1
[root@dangerzo dangerzo]# cat good | grep sbin > sbin1.txt
[root@dangerzo dangerzo]# ls
abab good grep.txt sbin1.txt want_3 want_4 want_5 want_6 wanted_1
[root@dangerzo dangerzo]# cat good
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 13:34 ? 00:00:04 init
root 2 1 0 13:34 ? 00:00:00 [keventd]
root 3 1 0 13:34 ? 00:00:00 [kapmd]
root 4 1 0 13:34 ? 00:00:00 [ksoftirqd_CPU0]
root 9 1 0 13:34 ? 00:00:00 [bdflush]
root 5 1 0 13:34 ? 00:00:00 [kswapd]
root 6 1 0 13:34 ? 00:00:00 [kscand/DMA]
root 7 1 0 13:34 ? 00:00:00 [kscand/Normal]
root 8 1 0 13:34 ? 00:00:00 [kscand/HighMem]
root 10 1 0 13:34 ? 00:00:00 [kupdated]
root 11 1 0 13:34 ? 00:00:00 [mdrecoveryd]
root 15 1 0 13:34 ? 00:00:00 [kjournald]
root 73 1 0 13:34 ? 00:00:00 [khubd]
root 1258 1 0 13:34 ? 00:00:00 [kjournald]
root 1259 1 0 13:34 ? 00:00:00 [kjournald]
root 1571 1 0 13:35 ? 00:00:00 syslogd -m 0
root 1575 1 0 13:35 ? 00:00:00 klogd -x
rpc 1585 1 0 13:35 ? 00:00:00 [portmap]
rpcuser 1604 1 0 13:35 ? 00:00:00 [rpc.statd]
root 1671 1 0 13:35 ? 00:00:00 /usr/sbin/apmd -p 10 -w 5 -W -P
root 1721 1 0 13:35 ? 00:00:00 /usr/sbin/sshd
root 1735 1 0 13:35 ? 00:00:00 xinetd -stayalive -reuse -pidfil
root 1771 1 0 13:35 ? 00:00:00 [sendmail]
smmsp 1780 1 0 13:35 ? 00:00:00 [sendmail]
root 1790 1 0 13:35 ? 00:00:00 gpm -t imps2 -m /dev/mouse
root 1799 1 0 13:35 ? 00:00:00 crond
root 1810 1 0 13:35 ? 00:00:00 cupsd
daemon 1860 1 0 13:35 ? 00:00:00 [atd]
root 1869 1 0 13:35 tty2 00:00:00 /sbin/mingetty tty2
root 1870 1 0 13:35 tty3 00:00:00 /sbin/mingetty tty3
root 1871 1 0 13:35 tty4 00:00:00 /sbin/mingetty tty4
root 1872 1 0 13:35 tty5 00:00:00 /sbin/mingetty tty5
root 1873 1 0 13:35 tty6 00:00:00 /sbin/mingetty tty6
root 15227 1 0 14:49 ? 00:00:00 [login]
dangerzo 15228 15227 0 14:50 tty1 00:00:00 -bash
root 15337 15228 0 14:54 tty1 00:00:00 [su]
root 15338 15337 0 14:54 tty1 00:00:00 -bash
root 15388 15338 0 15:00 tty1 00:00:00 ps -ef
[root@dangerzo dangerzo]# cat sbin1.txt
root 1671 1 0 13:35 ? 00:00:00 /usr/sbin/apmd -p 10 -w 5 -W -P
root 1721 1 0 13:35 ? 00:00:00 /usr/sbin/sshd
root 1869 1 0 13:35 tty2 00:00:00 /sbin/mingetty tty2
root 1870 1 0 13:35 tty3 00:00:00 /sbin/mingetty tty3
root 1871 1 0 13:35 tty4 00:00:00 /sbin/mingetty tty4
root 1872 1 0 13:35 tty5 00:00:00 /sbin/mingetty tty5
root 1873 1 0 13:35 tty6 00:00:00 /sbin/mingetty tty6
[root@dangerzo dangerzo]#
자자 이것의 의미는 우선 맨처음의 명령어를 보자
cat good | grep sbin > sbin1.txt
cat good -> good 파일을 보여줘
| -> 또 그리고
grep sbin -> sbin 이라는 문자가 있는것만
> sbin1.txt -> sbin1.txt 이라는 파일에다가 입력해줘
결론은 sbin1.txt 라는 파일이 만들어 졌습니다. 이파일안에는 cat good | grep sbin
의 결과물이 저장이 되있죠...
[root@dangerzo dangerzo]#
[root@dangerzo dangerzo]# cat good | grep ks >> sbin1.txt
[root@dangerzo dangerzo]# ls
abab good grep.txt sbin1.txt want_3 want_4 want_5 want_6 wanted_1
[root@dangerzo dangerzo]# cat sbin1.txt
root 1671 1 0 13:35 ? 00:00:00 /usr/sbin/apmd -p 10 -w 5 -W -P
root 1721 1 0 13:35 ? 00:00:00 /usr/sbin/sshd
root 1869 1 0 13:35 tty2 00:00:00 /sbin/mingetty tty2
root 1870 1 0 13:35 tty3 00:00:00 /sbin/mingetty tty3
root 1871 1 0 13:35 tty4 00:00:00 /sbin/mingetty tty4
root 1872 1 0 13:35 tty5 00:00:00 /sbin/mingetty tty5
root 1873 1 0 13:35 tty6 00:00:00 /sbin/mingetty tty6
root 4 1 0 13:34 ? 00:00:00 [ksoftirqd_CPU0]
root 5 1 0 13:34 ? 00:00:00 [kswapd]
root 6 1 0 13:34 ? 00:00:00 [kscand/DMA]
root 7 1 0 13:34 ? 00:00:00 [kscand/Normal]
root 8 1 0 13:34 ? 00:00:00 [kscand/HighMem]
[root@dangerzo dangerzo]#
자 결과가 어떻죠??
붙여넣기가 됐습니다. 저장하는 파일이름이 같을 경우에는 그 뒷행렬부터 바로 붙여 넣기를 하고
">" 한번만 쓰게 되는경우에는 파일이름이 같으면 덮어쓰기가 됩니다....
그 이상은 아직 ~~ ^^::
'Linux > Beginner Document' 카테고리의 다른 글
su 의 간단한 이용방법 (0) | 2017.11.22 |
---|---|
whoami, who am i, id, groups 의 간단한 이용방법 (0) | 2017.11.22 |
mount 의 간단한 이용 (0) | 2017.11.22 |
whereis 와 which 의 간단한 사용법 (0) | 2017.11.22 |
locate 의 간단한 사용방법 (0) | 2017.11.22 |