Command Table Link

꽃과 나비·2022년 4월 29일

Filter & Search

awk

Description
awk 명령어는 C언어에서 쓰는 체계를 쉘에 그대로 가져올 수 있다. 필드를 뽑아 낼 때 아주 유용하다.

* cat filename | awk '{print $3}' 		# 이렇게 넘겨줘도 되고 
* awk '{print $3}' /file 				# 뒤에다가 써줘도 된다.

Link
1 Basic

자주쓰는 체계

1. 	cat $TMP3 | awk -F: '{print $1 " : " $7}' > $TMP1 # 

2.	awk -F: '$3 < 200 || $3 > 60000 {print $0}' /etc/passwd

TIME Conversoin

awk -F\# '/^#1[0-9]{9}$/ { if(cmd) printf "%s\n %s\n",ts,cmd; ts=strftime("%F %T",$2); cmd="" } !/^#1[0-9]{9}$/ { if(cmd)cmd=cmd "\n" $0; else cmd=$0 }' ~/.bash_history

sed

Description
sed 명령어는 특정 문자열 찾고 바꾸기, 라인 제한해서 출력하기,

1. 	(p CMD)
	sed -n '1,3p' /etc/hosts 
	sed -n '10,$p' /etc/passwd    
    
2. sed '/linux200/s/192.168.20.200/172.16.20.200/' /etc/hosts > /tmp/file1

Link
1 sed 명령어의 자세한 설명

자주쓰는 체계

1. 

grep

Description

자주쓰는 체계

fgrep

Description

자주쓰는 체계

egrep

Description

자주쓰는 체계

cut

Description

자주쓰는 체계

profile
Nice meet you!!

0개의 댓글