'word count'에 해당되는 글 1건

  1. 2017.01.19 [Ubuntu] Word Count

[Ubuntu] Word Count

OS/Linux 2017. 1. 19. 15:47

Ubuntu 환경의 쉘에서 특정 word를 count하거나 특정 파일의 라인수를 카운트하는 wc 명령에 대해 알아보자.


$ wc --help

Usage: wc [OPTION]... [FILE]... or: wc [OPTION]... --files0-from=F Print newline, word, and byte counts for each FILE, and a total line if more than one FILE is specified. A word is a non-zero-length sequence of characters delimited by white space. With no FILE, or when FILE is -, read standard input. The options below may be used to select which counts are printed, always in the following order: newline, word, character, byte, maximum line length. -c, --bytes print the byte counts -m, --chars print the character counts -l, --lines print the newline counts --files0-from=F read input from the files specified by NUL-terminated names in file F; If F is - then read names from standard input -L, --max-line-length print the maximum display width -w, --words print the word counts --help display this help and exit --version output version information and exit GNU coreutils online help: <http://www.gnu.org/software/coreutils/> Full documentation at: <http://www.gnu.org/software/coreutils/wc> or available locally via: info '(coreutils) wc invocation'

wc 명령은 다음과 같이 여러가지로 이용가능하다.
  • 특정 파일의 라인수 카운트

$ wc -l test.md

42 test.md
  • 특정 문자 카운트

    $ cat test.md | grep config | wc -l

    4 $ cat /proc/cpuinfo | grep processor | wc -l 8


    'OS > Linux' 카테고리의 다른 글

    [Ubuntu] sudo 권한 등록  (0) 2017.08.09
    [Ubuntu] hostname 변경  (0) 2017.01.19
    [Ubuntu] Memory 확인  (0) 2017.01.19
    [Ubuntu] Filesystem 용량 확인  (0) 2017.01.19
    [Ubuntu] 커널버전 및 Ubuntu 버전 확인  (0) 2017.01.18
    Posted by leechwin
    ,