2021. 2. 9. 08:20ㆍ컴퓨터_Com/컴퓨터_Com
GNU Awk User's Guide www.gnu.org/software/gawk/manual/html_node/index.html#SEC_Contents
Top (The GNU Awk User’s Guide)
The GNU Awk User’s Guide General Introduction This file documents awk, a program that you can use to select particular records in a file and perform operations upon them. Copyright © 1989, 1991, 1992, 1993, 1996–2005, 2007, 2009–2020 Free Software F
www.gnu.org
1. printf (www.gnu.org/software/gawk/manual/html_node/Printf-Examples.html)
Printf Examples (The GNU Awk User’s Guide)
5.5.4 Examples Using printf The following simple example shows how to use printf to make an aligned table: awk '{ printf "%-10s %s\n", $1, $2 }' mail-list This command prints the names of the people ($1) in the file mail-list as a string of 10 characters t
www.gnu.org
printf를 사용하면 출력되는 숫자나 글자의 양식을 정할 수 있다. BEGIN 안에 머리글을 넣으면 한번만 출력되기 때문에 머리글은 BEGIN에 넣는 것이 좋다. %-10s의 s는 string을 의미하는데 숫자라고 편집 없이 동일한 칸에 출력하려면 s를 사용하는 것이 좋다. 더불어 format을 사용하면 출력 양식을 반복하지 않아도 된다.
'컴퓨터_Com > 컴퓨터_Com' 카테고리의 다른 글
노션 단축키 (0) | 2023.11.17 |
---|---|
파일 개수 세기 (0) | 2022.06.03 |
Shell Script (1) | 2020.05.08 |
CSV 파일 합치기 (0) | 2019.11.07 |
[awk/sed/grep] text 파일에서 일부분 추출, 편집 (0) | 2019.09.09 |