[ cut -cchars file ] // option "-c"
[root@vmcentos ~]# who
root pts/1 2009-06-05 10:46 (192.168.2.5)
root :0 2009-06-05 10:53
root pts/2 2009-06-05 10:54 (:0.0)
root pts/3 2009-06-05 10:58 (192.168.2.5)
extract characters 5 through the end of the line from each line of file.
파일의 각 줄에서 5번째 문자부터 줄의 끝까지 추출
[root@vmcentos ~]# who | cut -c5-
pts/1 2009-06-05 10:46 (192.168.2.5)
:0 2009-06-05 10:53
pts/2 2009-06-05 10:54 (:0.0)
pts/3 2009-06-05 10:58 (192.168.2.5)
extract characters 1 through 5 from each line of file.
파일의 각 줄에서 1~5번째 문자만 추출
[root@vmcentos ~]# who |cut -c-5 // who | cut -c1-5
root
root
root
root
extract characters 1 through 5 and 20 through the end of the line from each line of file.
파일의 각 줄에서 1~5번 째와, 20번 째부터 줄의 마지막 까지 추출
[root@vmcentos ~]# who | cut -c-5,20-
root 2009-06-05 10:46 (192.168.2.5)
root 2009-06-05 10:53
root 2009-06-05 10:54 (:0.0)
root 2009-06-05 10:58 (192.168.2.5)
extract characters 23 through 38 from each line of file.
파일의 각 줄에서 23~38번 째 까지 추출
[root@vmcentos ~]# who | cut -c 23-38
2009-06-05 10:46
2009-06-05 10:53
2009-06-05 10:54
2009-06-05 10:58
[ cut -ddchar -ffields file ] // option "-d" and "-f"
dchar is the character that delimits each field of the data, and fields specifies the fields to be extracted from file.
if option "-d" is not given, cut assumes that a tab character is the delimiter by default.
dchar은 구분자, fields는 추출할 필드.
"-d" 옵션이 없이 "-f" 만 사용하면 탭을 구분자로 사용함.
[root@vmcentos ~]# cut -d: -f1 /etc/passwd
root
bin
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
gopher
[root@vmcentos ~]# cut -d: -f1,7 /etc/passwd
root:/bin/bash
bin:/sbin/nologin
daemon:/sbin/nologin
adm:/sbin/nologin
lp:/sbin/nologin
sync:/bin/sync
shutdown:/sbin/shutdown
halt:/sbin/halt
mail:/sbin/nologin
- 2009/06/05 14:10
- movestar.egloos.com/2400231
- 덧글수 : 0



덧글