wc Command 参考

wc Command

Purpose

       Counts the number of lines, words, bytes, or characters in a file.

Syntax

       wc [ -c | -m ] [  -l ] [ -w ] [ File ... ]

       wc  -k [ -c ] [  -l ] [ -w ] [ File ... ]

Description

       By default, the wc command counts the number of lines, words, and bytes in the files
       specified by the File parameter. The command writes the number of newline characters, words,
       and bytes to the standard output and keeps a total count for all named files.

       When you use the File parameter, the wc command displays the file names as well as the
       requested counts. If you do not specify a file name for the File parameter, the wc command
       uses standard input.

       The wc command is affected by the LANG, LC_ALL, LC_CTYPE, and LC_MESSAGES environment
       variables.

       The wc command considers a word to be a string of characters of non-zero length which are
       delimited by a white space (for example SPACE , TAB).

Flags

       -c
            Counts bytes unless the -k flag is specified. If the -k flag is specified, the wc
            command counts characters.
       -k
            Counts characters. Specifying the -k flag is equivalent to specifying the -klwc flag. If
            you use the -k flag with other flags, then you must include the -c flag. Otherwise, the
            -k flag is ignored. For more information, see examples 4 and 5.

            Note: This flag is to be withdrawn in a future release.

       -l
            Counts lines.
       -m
            Counts characters. This flag cannot be used with the -c flag.
       -w
            Counts words. A word is defined as a string of characters delimited by spaces, tabs, or
            newline characters.
                 Note:  If no flag is specified, wc by default counts the lines, words, bytes in a
                 file or from standard input.

Exit Status

       This command returns the following exit values:
       0
            The command ran successfully.

       >0
            An error occurred.

Examples
       1    To display the line, word, and byte counts of a file, enter:

            wc chap1

            The wc command displays the number of lines, words, and bytes in the chap1 file.
       2    To display only byte and word counts, enter:

            wc -cw chap*

            The wc command displays the number of bytes and words in each file that begins with
            chap. The command also displays the total number of bytes and words in these files.
       3    To display the line, word, and character counts of a file, enter:

            wc -k chap1

            The wc command displays the number of lines, words, and characters in the chap1 file.
       4    To display the word and character counts of a file, enter:

            wc -kcw chap1

            The wc command displays the number of characters and words in the chap1 file.
       5    To use the wc command on standard input, enter:

            wc -klw

            The wc command displays the number of lines and words in standard input. The -k flag is
            ignored.
       6    To display the character counts of a file, enter:

            wc -m chap1

            The wc command displays the number of characters in the chap1 file.
       7    To use the wc command on standard input, enter:

            wc -mlw

            The wc command displays the number of lines, words, and characters in standard input.

Files

       /usr/bin/wc, /bin/wc
            Contains the wc command.
       /usr/ucb/wc
            Contains the symbolic link to the wc command.

Related Information

       Files and Input and output redirection in Operating system and device management.

       Understanding Locale Environment Variables in AIX 5L Version 5.3 National Language Support
       Guide and Reference.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值