必选参数对长短选项同时适用。 +首页[:末页], --pages=首页[:末页] 在指定的首页/末页处开始/停止打印 -列数, --columns=列数 输出指定的列数。如果指定了-a 选项,则从上到下列印。 程序会自动在每一页均衡每列占用的行数。 -a, --across 设置每列从上到下输出,配合"-列数"选项一起使用 -c, --show-control-chars 使用头标(^G)和八进制反斜杠标记 -d, --double-space 加倍输出空白区域 -D, --date-format=格式 使用遵循指定格式的页眉日期 -e[字符[宽度]], --expand-tabs[=字符[宽度]] 扩展输入的字符(制表符) 到制表符宽度(8) -F, -f, --form-feed 使用出纸页页标代替新行作为页面间的分隔符 (使用-F 选项时报头为3 行,不使用时为5 行) -h, --header=页眉 在页眉中使用居中的指定字符代替文件名 -h "" 输出一个空行,不要使用 -h"" -i[字符[宽度]], --output-tabs[=字符[宽度]] 使用指定字符(或制表符)代替空格不足到指定制表符宽度(默认8) -J, --join-lines 合并整个行,关闭-W 选项的行截断,不使用栏调整,使用 --sep-string[=字符串] 设置分隔符 -l, --length=PAGE_LENGTH set the page length to PAGE_LENGTH (66) lines (default number of lines of text 56, and with -F 63). implies -t if PAGE_LENGTH <= 10 -m, --merge print all files in parallel, one in each column, truncate lines, but join lines of full length with -J -n[分隔符[位数]], --number-lines[=分隔符[位数]] 显示行号,使用指定(默认5) 位数,后接分隔符(默认TAB) 默认从输入文件的第一行开始计数 -N, --first-line-number=数字 从首页的首行以指定数字开始计数(参看"+首页") -o, --indent=缩进量 将每行缩进(默认0)个空格,不影响-w 或-W 参数, 缩进亮的值将被加入页面宽度 -r, --no-file-warnings 当文件无法打开时忽略警告 -s[CHAR], --separator[=CHAR] separate columns by a single character, default for CHAR is the <TAB> character without -w and 'no char' with -w. -s[CHAR] turns off line truncation of all 3 column options (-COLUMN|-a -COLUMN|-m) except -w is set -S[STRING], --sep-string[=STRING] separate columns by STRING, without -S: Default separator <TAB> with -J and <space> otherwise (same as -S" "), no effect on column options -t, --omit-header omit page headers and trailers; implied if PAGE_LENGTH <= 10 -T, --omit-pagination 按照输入文件中的设置忽略页眉和页脚并除去所有分页记号 -v, --show-nonprinting 使用八进制反斜杠标记 -w, --width=页面宽度 为多栏页面输出将设置为指定的字符数(默认72), 仅当-s[char] 选项不启用时有效(即保持默认值 72)。 -W, --page-width=页宽 总是将页宽设置为指定的(默认72)字符数, 除非-J 选项启用总是截断行,此参数与-S 或-s 冲突 --help 显示此帮助信息并退出 --version 显示版本信息并退出
$ fmt --help 用法:fmt [-宽度] [选项]... [文件]... Reformat each paragraph in the FILE(s), writing to standard output. The option -WIDTH is an abbreviated form of --width=DIGITS.
必选参数对长短选项同时适用。 -c, --bytes=[-]NUM print the first NUM bytes of each file; with the leading '-', print all but the last NUM bytes of each file -n, --lines=[-]NUM print the first NUM lines instead of the first 10; with the leading '-', print all but the last NUM lines of each file -q, --quiet, --silent 不显示包含给定文件名的文件头 -v, --verbose 总是显示包含给定文件名的文件头 -z, --zero-terminated line delimiter is NUL, not newline --help 显示此帮助信息并退出 --version 显示版本信息并退出
用法:tail [选项]... [文件]... Print the last 10 lines of each FILE to standard output. With more than one FILE, precede each with a header giving the file name.
如果没有指定文件,或者文件为"-",则从标准输入读取。
必选参数对长短选项同时适用。 -c, --bytes=[+]NUM output the last NUM bytes; or use -c +NUM to output starting with byte NUM of each file -f, --follow[={name|descriptor}] output appended data as the file grows; an absent option argument means 'descriptor' -F same as --follow=name --retry -n, --lines=[+]NUM output the last NUM lines, instead of the last 10; or use -n +NUM to output starting with line NUM --max-unchanged-stats=N with --follow=name, reopen a FILE which has not changed size after N (default 5) iterations to see if it has been unlinked or renamed (this is the usual case of rotated log files); with inotify, this option is rarely useful --pid=PID with -f, terminate after process ID, PID dies -q, --quiet, --silent never output headers giving file names --retry keep trying to open a file if it is inaccessible -s, --sleep-interval=N with -f, sleep for approximately N seconds (default 1.0) between iterations; with inotify and --pid=P, check process P at least once every N seconds -v, --verbose always output headers giving file names -z, --zero-terminated line delimiter is NUL, not newline --help 显示此帮助信息并退出 --version 显示版本信息并退出
$ head /usr/include/stdio.h /* Define ISO C stdio on top of C++ iostreams. Copyright (C) 1991-2018 Free Software Foundation, Inc. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful, $ head -5 /usr/include/stdio.h /* Define ISO C stdio on top of C++ iostreams. Copyright (C) 1991-2018 Free Software Foundation, Inc. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or $ tail /usr/include/stdio.h #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function # include <bits/stdio2.h> #endif #ifdef __LDBL_COMPAT # include <bits/stdio-ldbl.h> #endif
仅使用f -b, -c 或-f 中的一个。每一个列表都是专门为一个类别作出的,或者您可以用逗号隔 开要同时显示的不同类别。您的输入顺序将作为读取顺序,每个仅能输入一次。 Each range is one of:
N N'th byte, character or field, counted from 1 N- from N'th byte, character or field, to end of line N-M from N'th to M'th (included) byte, character or field -M from first to M'th (included) byte, character or field
使用 join 连接字段
Linux 下的 join 可以连接不同的文件,使得具有相同 key 值的记录信息连接到一起。它会根据指定栏位,找到两个文件中指定栏位内容相同的行,将他们合并,并根据要求的格式输出内容。
-a FILENUM also print unpairable lines from file FILENUM, where FILENUM is 1 or 2, corresponding to FILE1 or FILE2 -e EMPTY replace missing input fields with EMPTY -i, --ignore-case ignore differences incase when comparing fields -j FIELD equivalent to '-1 FIELD -2 FIELD' -o FORMAT obey FORMAT while constructing output line -t CHAR use CHAR as input and output field separator -v 文件编号 类似 -a 文件编号,但禁止组合输出行 -1 域 在文件1 的此域组合 -2 域 在文件2 的此域组合 --check-order 检查输入行是否正确排序,即使所有输入行均是成对的 --nocheck-order 不检查输入是否正确排序 --header 将首行视作域的头部,直接输出而不对其进行匹配 -z, --zero-terminated line delimiter is NUL, not newline --help 显示此帮助信息并退出 --version 显示版本信息并退出
$ cat linux.wiki Linux (/ˈlɪnəks/ (About this soundlisten) LIN-əks)[9][10] is a family of free and open-source software operating systems based on the Linux kernel,[11] an operating system kernel first released on September 17, 1991 by Linus Torvalds.[12][13][14] Linux is typically packaged in a Linux distribution (or distro for short). Linux is one of the most prominent examples of free and open-source software collaboration. The source code may be used, modified and distributed—commercially or non-commercially—by anyone under the terms of its respective licenses, such as the GNU General Public License. $ tr 'a-z''A-Z' <linux.wiki >linux.wiki.upper $ cat linux.wiki.upper LINUX (/ˈLɪNəKS/ (ABOUT THIS SOUNDLISTEN) LIN-əKS)[9][10] IS A FAMILY OF FREE AND OPEN-SOURCE SOFTWARE OPERATING SYSTEMS BASED ON THE LINUX KERNEL,[11] AN OPERATING SYSTEM KERNEL FIRST RELEASED ON SEPTEMBER 17, 1991 BY LINUS TORVALDS.[12][13][14] LINUX IS TYPICALLY PACKAGED IN A LINUX DISTRIBUTION (OR DISTRO FOR SHORT). LINUX IS ONE OF THE MOST PROMINENT EXAMPLES OF FREE AND OPEN-SOURCE SOFTWARE COLLABORATION. THE SOURCE CODE MAY BE USED, MODIFIED AND DISTRIBUTED—COMMERCIALLY OR NON-COMMERCIALLY—BY ANYONE UNDER THE TERMS OF ITS RESPECTIVE LICENSES, SUCH AS THE GNU GENERAL PUBLIC LICENSE.
用法:tr [选项]... SET1 [SET2] Translate, squeeze, and/or delete characters from standard input, writing to standard output.
-c, -C, --complement use the complement of SET1 -d, --delete delete characters in SET1, do not translate -s, --squeeze-repeats replace each sequence of a repeated character that is listed in the last specified SET, with a single occurrence of that character -t, --truncate-set1 first truncate SET1 to length of SET2 --help 显示此帮助信息并退出 --version 显示版本信息并退出