"Awk 마지막 컬럼 출력"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
 
(사용자 2명의 중간 판 7개는 보이지 않습니다)
5번째 줄: 5번째 줄:


==명령어==
==명령어==
;명령어 (마지막 컬럼 출력)
{{소스헤더|마지막 컬럼 출력}}
<source lang='bash'>
<syntaxhighlight lang='bash'>
원본출력 | awk '{print $NF}'
원본출력 | awk '{print $NF}'
awk '{print $NF}' 원본파일
awk '{print $NF}' 원본파일
</source>
</syntaxhighlight>


;명령어 (마지막 2개 컬럼 출력)
{{소스헤더|마지막 2개 컬럼 출력}}
<source lang='bash'>
<syntaxhighlight lang='bash'>
원본출력 | awk '{print $(NF-1)"\t"$NF}'
원본출력 | awk '{print $(NF-1)"\t"$NF}'
awk '{print $(NF-1)"\t"$NF}' 원본파일
awk '{print $(NF-1)"\t"$NF}' 원본파일
</source>
</syntaxhighlight>


==실행예시==
==실행예시==
;실행예시 (원본출력)
{{소스헤더|실행예시 (원본출력)}}
<source lang='dos'>
<syntaxhighlight lang='console'>
[root@jmnote ~]# df -Pk
[root@zetawiki ~]# df -Pk
Filesystem        1024-blocks      Used Available Capacity Mounted on
Filesystem        1024-blocks      Used Available Capacity Mounted on
/dev/mapper/VolGroup00-LogVol00  27678892  6037884  20212324      24% /
/dev/mapper/VolGroup00-LogVol00  27678892  6037884  20212324      24% /
/dev/xvda1              101086    36768    59099      39% /boot
/dev/xvda1              101086    36768    59099      39% /boot
tmpfs                  524288        0    524288      0% /dev/shm
tmpfs                  524288        0    524288      0% /dev/shm
</source>
</syntaxhighlight>
;실행예시 (마지막 컬럼 1개)
{{소스헤더|실행예시 (마지막 컬럼 1개)}}
<source lang='dos'>
<syntaxhighlight lang='console'>
[root@jmnote ~]# df -Pk | awk '{print $NF}'
[root@zetawiki ~]# df -Pk | awk '{print $NF}'
on
on
/
/
/boot
/boot
/dev/shm
/dev/shm
</source>
</syntaxhighlight>
;실행예시 (마지막 컬럼 2개)
{{소스헤더|실행예시 (마지막 컬럼 2개)}}
<source lang='dos'>
<syntaxhighlight lang='console'>
[root@jmnote ~]# df -Pk | awk '{print $(NF-1)"\t"$NF}'
[root@zetawiki ~]# df -Pk | awk '{print $(NF-1)"\t"$NF}'
Mounted on
Mounted on
24% /
24% /
39% /boot
39% /boot
0% /dev/shm
0% /dev/shm
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==
48번째 줄: 48번째 줄:
*[[awk]]
*[[awk]]


==참고 자료==
==참고==
*http://stackoverflow.com/questions/4304917/how-to-print-last-two-columns-using-awk
*http://stackoverflow.com/questions/4304917/how-to-print-last-two-columns-using-awk


[[분류: awk]]
[[분류: awk]]

2020년 11월 2일 (월) 02:39 기준 최신판

awk 마지막 컬럼 출력
awk 마지막 컬럼 2개 출력
awk 마지막 전 컬럼 출력

1 명령어[ | ]

마지막 컬럼 출력
원본출력 | awk '{print $NF}'
awk '{print $NF}' 원본파일
마지막 2개 컬럼 출력
원본출력 | awk '{print $(NF-1)"\t"$NF}'
awk '{print $(NF-1)"\t"$NF}' 원본파일

2 실행예시[ | ]

실행예시 (원본출력)
[root@zetawiki ~]# df -Pk
Filesystem         1024-blocks      Used Available Capacity Mounted on
/dev/mapper/VolGroup00-LogVol00  27678892   6037884  20212324      24% /
/dev/xvda1              101086     36768     59099      39% /boot
tmpfs                   524288         0    524288       0% /dev/shm
실행예시 (마지막 컬럼 1개)
[root@zetawiki ~]# df -Pk | awk '{print $NF}'
on
/
/boot
/dev/shm
실행예시 (마지막 컬럼 2개)
[root@zetawiki ~]# df -Pk | awk '{print $(NF-1)"\t"$NF}'
Mounted	on
24%	/
39%	/boot
0%	/dev/shm

3 같이 보기[ | ]

4 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}