Shell -- 문자 캡 처 명령 cut awk sed
printf ' '
:
%ns: 。n ,
%ni: 。n ,
%m.nf: 。m,n , 。 %8.2f 8 , 2 ,6 。 123456.78
;
\a:
\b: , backspace
\f:
:
\r: ,enter
\t: , Tab
\v: 。
printf '%s' $(cat test.txt)
cut 필드 추출 명령
cut 명령
cut [ ]
:
-f :
-d : , (Tab, )
실례:
cut -d ":" -f 1,3
awk 명령
awk 형식
awk ' 1{ 1} 2{ 2}…'
(Pattern):
— 。 :X>10 x 10
(Action):
—
—
예 를 들 면:
# ($0 )
awk '{printf $2 "\t" $4 "
"}' student.txt
# print ,print Linux , awk
awk '{print $2 "\t" $4 }' student.txt
#
df -h|awk '{print $5}'
sed 명령
sed 는 거의 모든 UNIX 플랫폼 (Linux 포함) 에 포 함 된 경량급 스 트림 편집기 입 니 다.sed 는 주로 데 이 터 를 선택, 교체, 삭제, 추가 명령 을 하 는 데 사 용 됩 니 다.
sed [ ] '[ ]'
:
-n: sed , sed 。
-e: sed 。
-i: sed , 。
:
a: ,
c: , c
i: ,
d: ,
p: ,
s: , 。 “ s/ / /g”
실례:
# ,
sed '2p' a.txt
#
sed -n '2p' a.txt
# , ,
sed '2,4d' a.txt
# hello world
sed '2a hello world' a.txt
# hello world
sed '2i hello world' a.txt
# hello world
sed '2c hello world' a.txt
# 70 100
sed '4s/70/100/' a.txt
# 70 100
sed '4s/70/100/g' a.txt
# 70 100
sed 's/70/100/g' a.txt
# 70 100
sed 's/70/100/' a.txt
#
sed -i '4s/70/100/' a.txt
#
sed -e '1s/70/100/g;2s/80/100/g' a.txt
# (-e , -i )
sed -i -e '1s/70/100/g;2s/80/100/g' a.txt