cat – concatenate and print files
cat <file name>
cat <file1> <file2>
긴 파일을 출력할때 편함 페이지 전환가능 ~! man 페이지처럼!
less <filename>
결합하고 출력하는데 순서가 반대임 각각의 줄들을 마지막부터 출력함
역순으로 출력
-> mac에는 없는듯?;
rev – reverse lines of a file
파일에 영향 주지 않음!
dduui-MacBookPro:Linux ddu$ cat colors.txt
red
orange
yellow
green
blue
indigo
violet
dduui-MacBookPro:Linux ddu$ rev colors.txt
der
egnaro
wolley
neerg
eulb
ogidni
teloiv
head – display first lines of a file
옵션 없으면 기본 열줄을 출력함
옵션
head -3(라인 갯수) <filename>
dduui-MacBookPro:Linux ddu$ head countries.txt
Afghanistan
Albania
Algeria
Andorra
Angola
Antigua & Deps
Argentina
Armenia
Australia
Austria
tail – display the last part of a file
dduui-MacBookPro:Linux ddu$ tail countries.txt
Uruguay
Uzbekistan
Vanuatu
Vatican City
Venezuela
Vietnam
Yemen
Zambia
Zimbabwe
옵션
tail -n(라인수) 파일명
tail -f 파일명
업데이트 된것을 다시 불러옴??
dduui-MacBookPro:Linux ddu$ head -n 5 countries.txt
Afghanistan
Albania
Algeria
Andorra
Angola
wc – word, line, character, and byte count
c
The number of bytes in each input file is written to the standard output. This
will cancel out any prior usage of the -m option.
l
The number of lines in each input file is written to the standard output.
m
The number of characters in each input file is written to the standard output. If
the current locale does not support multibyte characters, this is equivalent to the
-c option. This will cancel out any prior usage of the -c option.
줄수, 단어수, 바이트수 순으로 출력됨
dduui-MacBookPro:Linux ddu$ wc countries.txt
197 245 1844 countries.txt
dduui-MacBookPro:Linux ddu$ wc colors.txt
8 7 44 colors.txt
sort – sort or merge records (lines) of text and binary files
파일 자체의 내용은 바꾸지 않고 출력만 변경!
dduui-MacBookPro:Linux ddu$ cat colors.txt
red
orange
yellow
green
blue
indigo
violet
dduui-MacBookPro:Linux ddu$ sort colors.txt
blue
green
indigo
orange
red
violet
yellow
dduui-MacBookPro:Linux ddu$ cat letters.txt
A
D
T
G
F
W
yw
D
x
X
Q
e
dduui-MacBookPro:Linux ddu$ sort letters.txt
A
D
D
F
G
Q
T
W
X
e
x
yw
dduui-MacBookPro:Linux ddu$ cat prices
49.00
19.00
0.50
199.99
5.00
13
dduui-MacBookPro:Linux ddu$ sort prices
0.50
13
19.00
199.99
49.00
5.00
dduui-MacBookPro:Linux ddu$
dduui-MacBookPro:Linux ddu$ sort -n prices
0.50
5.00
13
19.00
49.00
199.99
dduui-MacBookPro:Linux ddu$
dduui-MacBookPro:Linux ddu$ cat prices
1열 2열 3열
racecar 49.00 3
chocolate 19.00 12
pancle 0.50 49
house 199.99 1
pizza 5.00 1
fisha 13 2
//2열을 사용해 정렬
dduui-MacBookPro:Linux ddu$ sort -nk2 prices
pancle 0.50 49
pizza 5.00 1
fisha 13 2
chocolate 19.00 12
racecar 49.00 3
house 199.99 1