Published Book on Amazon
All of IOT Starting with the Latest Raspberry Pi from Beginner to Advanced – Volume 1 | |
All of IOT Starting with the Latest Raspberry Pi from Beginner to Advanced – Volume 2 |
출판된 한글판 도서
최신 라즈베리파이(Raspberry Pi)로 시작하는 사물인터넷(IOT)의 모든 것 – 초보에서 고급까지 (상) | |
최신 라즈베리파이(Raspberry Pi)로 시작하는 사물인터넷(IOT)의 모든 것 – 초보에서 고급까지 (하) |
Original Book Contents
10.9.2 "wc" Command
This command counts and returns the number of line, word, and byte in the specified file.
[Command Format]
wc [option] [directory/file] |
[Command Overview]
■ This calculates and reports the number of line, word, and byte in the specified file.
■ User privilege -- Normal user.
[Detail Description]
■ None
[Main Option]
-c, --bytes | print the byte counts |
-m, --chars | print the character counts |
-l, --lines | print the newline counts |
[Used Example]
First, there is a file "customer_product.txt" in the "testdata" directory of the "pi" account, and the file content is as follows.
pi@raspberrypi ~/testdata $ ls -l |
-rw-r--r-- 1 pi pi 62 Apr 23 13:06 customer_list.txt -rw-r--r-- 1 pi pi 123 Apr 23 13:00 customer_product.txt -rw-rw---- 2 pi pi 80 Apr 12 15:12 DebianManual.txt drwxr-xr-x 4 pi pi 4096 Apr 22 09:52 TestFolder01 drwxr-xr-x 2 pi pi 4096 Apr 10 13:32 TestFolder02 -rw-r--r-- 1 pi pi 656 Apr 22 09:30 test_for_editor.txt -rw-rw---- 1 pi pi 113 Apr 23 08:22 user_guide01.txt |
pi@raspberrypi ~/testdata $ cat customer_product.txt |
Microsoft PC Google Search IBM Super Computer Facebook SNS LG Electrics Samsung Mobile Sony Movie Hewlett-Packard Printer |
Now, let's run the "wc" command on this file. The result is as follows.
pi@raspberrypi ~/testdata $ wc customer_product.txt |
8 17 123 customer_product.txt |
In the above, three numbers and file names are displayed. The first number is the line number, the next number is the word number, and the last number is the byte number.
Now, let's get the line number for this file. To do this, you must use "-l" option.
pi@raspberrypi ~/testdata $ wc –l customer_product.txt |
8 customer_product.txt |
Now you can see that the other numbers disappear and only the line number is displayed.