cat /app/test.properties|grep "패턴"| awk -F"패턴(기본값은 공백)" '{print $2}'


    1. /app/test.properties 라는 파일이 아래와 같이 있다고 가정하자.


         test1 hello 실제출력값1

         test2 hello2 실제출력값2


여기서  실제 출력값2를 출력하고 싶으면 아래와 같이 명령어를 파이프로 연결하여 사용하면 된다.


1. cat /app/test.properties (파일을 읽는다)

2. grep "test2" (test2 가 있는 패턴이 있는 행을 찾아서 출력)

3. awk '{print $3}' (공백으로 열구분하여 "실제출력값3"를 출력. $0: 전체 문자열, $1: test1, $2: hello2, $3: 실제출력값2)


합치면 cat /app/test.properties | grep "test2" | awk '{print $3}'












+ Recent posts