-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e35e9a6
commit b093902
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# 유용한 AWK Command | ||
``` | ||
# filename을 통한 awk 명령어 활용 | ||
$ awk 'pattern' filename | ||
$ awk '{action}' filename | ||
$ awk 'pattern {action}' filename | ||
# 만약 filename을 지정하지 않으면 키보드 입력에 의한 표준입력을 받는다. | ||
# 조건식 | ||
$ ls -ltr | awk '$2 < 10' | ||
# 포멧팅 형식 사용 printf | ||
$ ls -ltr | awk '{printf "The filename/dir name is %s\n", $9}' | ||
# awk -f [awk 명령파일] [awk 명령을 적용할 텍스트 파일] | ||
# NR 변수는 1부터 시작해서 하나씩 증가 | ||
$ ls -ltr | awk '{printf "%d. The filename/dir name is %s\n", NR, $9}' | ||
# 비교표현식 | ||
# 비교표현식 - 어떤 값이 조건에 만족할 경우 수행 | ||
$ ls -ltr | awk ' $9 == "0." {printf "%d. The filename/dir name is %s\n", NR, $9}' | ||
``` |