用UNIX的cat命令用于给文本加行号
2008-04-23 13:34
225 查看
有时候需要给文本加上行号,用UNIX的cat命令可以进行这项工作。
cat命令的用法如下:
NAME
cat - concatenate, copy, and print files
SYNOPSIS
cat [-benrstuv] file ...
Options
cat recognizes the following options:
-b Omit line numbers from blank lines when -n option is
specified. If this option is specified, the -n option is
automatically selected.
-e Print a $ character at the end of each line (prior to the
new-line). If this option is specified, the -v option is
automatically selected.
-n Display output lines preceded by line numbers, numbered
sequentially from 1.
-r Replace multiple consecutive empty lines with one empty
line, so that there is never more than one empty line
between lines containing characters.
-s Silent option. cat suppresses error messages about non-
existent files, identical input and output, and write
errors. Normally, input and output files cannot have
identical names unless the file is a special file.
-t Print each tab character as ^I and form feed character as
^L. If this option is specified, the -v option is
automatically selected.
-u Do not buffer output (handle character-by-character).
Normally, output is buffered.
cat -n 可以加上行号,cat -b 也可以加上行号,但会忽略空行。
如下命令可以为file1加上空行后,输入为file2(空行也加上行号):
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
cat -n file1 > file2
如下命令可以为file1加上空行后,输入为file2(空行不加行号):
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
cat -b file1 > file2
cat命令的用法如下:
NAME
cat - concatenate, copy, and print files
SYNOPSIS
cat [-benrstuv] file ...
Options
cat recognizes the following options:
-b Omit line numbers from blank lines when -n option is
specified. If this option is specified, the -n option is
automatically selected.
-e Print a $ character at the end of each line (prior to the
new-line). If this option is specified, the -v option is
automatically selected.
-n Display output lines preceded by line numbers, numbered
sequentially from 1.
-r Replace multiple consecutive empty lines with one empty
line, so that there is never more than one empty line
between lines containing characters.
-s Silent option. cat suppresses error messages about non-
existent files, identical input and output, and write
errors. Normally, input and output files cannot have
identical names unless the file is a special file.
-t Print each tab character as ^I and form feed character as
^L. If this option is specified, the -v option is
automatically selected.
-u Do not buffer output (handle character-by-character).
Normally, output is buffered.
cat -n 可以加上行号,cat -b 也可以加上行号,但会忽略空行。
如下命令可以为file1加上空行后,输入为file2(空行也加上行号):
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
cat -n file1 > file2
如下命令可以为file1加上空行后,输入为file2(空行不加行号):
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
cat -b file1 > file2
相关文章推荐
- 用UNIX的cat命令用于给文本加行号 (转载)
- 【Unix/Linux】【命令】【文本工具】标准输出打印/连接文件——cat
- Linux基础文本查看命令之 cat,tac,more,less,head,tail
- unix cat命令
- linux用于查看文件内容 tail、cat、more、less、head 、sed 命令
- Linux中查看文本文件内容命令cat/tac/nl/more/less/head/tail/vi总结
- linux命令---用于查看文件内容cat,more,less,head,tail,sed
- unix 文本编辑命令巧用
- Linux显示文本的命令(cat, tac,more,less,head,tail,nl)
- 第七课:PATH:CP:MV:cat:head:tail等文本命令介绍:
- 显示文本命令大全(cat, tac, more,less,head,tail,nl,od)
- 【Unix/Linux】【命令】【文本工具】文件/输出分页显示——more
- 【Unix/Linux】【命令】【文本工具】vi
- Linux中查看文本文件内容命令cat/tac/nl/more/less/head/tail/vi总结
- UNIX文件目录管理基本命令之移动光标屏幕翻滚插入文本
- 【Linux命令详解】12、文本内容显示―[ cat、tac、more、less、tail、head]
- dos2unix命令(windows下编辑linux文本要用)
- Linux中查看文本文件内容命令cat/tac/nl/more/less/head/tail/vi总结
- linux命令之----sort命令用于将文本文件内容加以排序
- 文本处理命令 cat more less cut wc sort uniq