OS & Shell/Linux

[Linux] awk

냐옴 2015. 3. 3. 21:13

http://www.cyberciti.biz/faq/bash-scripting-using-awk/


# 출력

awk '{print}' test.txt

awk '{print}' /etc/passwd


# 라인 내용을 ':'로 컬럼 구분

awk -F':' '{print $1}' /etc/passwd

awk -F':' '{print $2}' /etc/passwd

awk -F':' '{print $3}' /etc/passwd

awk -F':' '{print $4}' /etc/passwd

awk -F':' '{print $5}' /etc/passwd


# 4번째 라인 출력

awk "NR==4{print;exit}" /proc/net/dev


# 구분자 공백

awk -F' ' '{print $5,$6,$7}' result.txt