用UNIX的cat命令用于给文本加行号 (转载)
转载:http://blog.csdn.net/vicant/article/details/2317721
有时候需要给文本加上行号,用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(空行也加上行号):
cat -n file1 > file2
如下命令可以为file1加上空行后,输入为file2(空行不加行号):
cat -b file1 > file2
用UNIX的cat命令用于给文本加行号 (转载)的更多相关文章
- cat命令详解
命令cat cat 命令用于连接文件并打印到标准输出设备上 语法格式: cat [-AbeEnstTuv] [--help] [--version] fileName 参数说明: -n 或 --num ...
- linux命令详解:cat命令
转:http://www.cnblogs.com/lwgdream/archive/2013/11/06/3409802.html 前言 cat命令用于读取文本文件,并且能够显示行号.特殊字符等. 使 ...
- linux学习(三)输入输出重定向和管道功能、cat命令、more命令
目录 输入输出重定向 输出重定向 管道功能 cat命令 more命令 @(输入输出重定向和管道功能) 输入输出重定向 输入重定向可以让用户将某个文件作为输入设备,输出重定向可以把某个文件作为输出设备, ...
- linux命令之------Cat命令
Cat命令 作用:cat命令用于连接文件并打印,查看文件内容: -n或--number:由1开始对所有输出的行数编号: -b或--number-nonblank:和-n相似,只不过对于空白行不做编号: ...
- Linux cat命令使用方法
今天小编为大家带来cat的使用方法命令:catcat 命令用于连接文件并打印到标准输出设备上.使用权限所有使用者 语法格式cat [-AbeEnstTuv] [–help] [–version] fi ...
- 每天一个Linux常用命令 cat命令
在Linux系统中,cat命令是一个文本输出命令,通常用来查看某个文档的内容.它有如下三个功能: 1.一次性显示整个文件 如:查看/etc/initab文件,可以使用命令:cat/etc/initta ...
- 【Linux常见命令】cat命令
cat - concatenate files and print on the standard output cat 命令用于连接文件并打印到标准输出设备上. 用法: 1. cat file 查看 ...
- cut命令用于按“列”提取文本字符,格式为“cut [参数] 文本”
8.cut命令 cut命令用于按"列"提取文本字符,格式为"cut [参数] 文本". 在Linux系统中,如何准确地提取出最想要的数据,这也是我们应该重点学习 ...
- 28个Unix/Linux的命令行神器_转
28个Unix/Linux的命令行神器 下面是Kristóf Kovács收集的28个Unix/Linux下的28个命令行下的工具,有一些是大家熟悉的,有一些是非常有用的,有一些是不为人知的.这些工具 ...
随机推荐
- oracle 启动监听报错TNS-12547: TNS:lost contact
https://blog.csdn.net/liqfyiyi/article/details/7534018
- [NOI2012(bzoj2879)(vijos1726)]美食节 (费用流)
2879: [Noi2012]美食节 Time Limit: 10 Sec Memory Limit: 512 MBSubmit: 2288 Solved: 1207[Submit][Status ...
- JVM(零):走入JVM
JVM(零):走入JVM 本系列主要讲述JVM相关知识,作为本系列的第一篇文章,本文从Java为什么是一个跨平台的语音开始介绍,逐步引入Java虚拟机的概念,并给出一个JVM相关知识图谱,可以让读者从 ...
- 转:Linux性能评测工具之一:gprof篇
1 简介 改进应用程序的性能是一项非常耗时耗力的工作,但是究竟程序中是哪些函数消耗掉了大部分执行时间,这通常都不是非常明显的.GNU 编译器工具包所提供了一种剖析工具 GNU profiler(gpr ...
- asterisk 问题
Q:SIP可以呼通,但听不到声音A:一般是NAT问题造成.如果Asterisk处在NAT的后面,则Asterisk的配置如下: ------------------------------------ ...
- 210 Course ScheduleII
/* * 210 Course ScheduleII * 2016-6-9 by Mingyang * http://www.jyuan92.com/blog/leetcode-course-sche ...
- httpclient失败重连机制
HttpClient 底层会默认超时自动重发3次,DefaultHttpRequestRetryHandler源码 /** * Create the request retry handler ...
- 【APUE】进程间通信之管道
管道是UNIX系统IPC最古老形式,并且所有UNIX系统都提供此种通信机制.管道由下面两种局限性: 1)历史上,它们是半双工的(即数据只能在一个方向上流动) 2)它们只能在具有公共祖先的进程之间使用. ...
- [RxJS] Use `lift` to Connect a `source` to a `subscriber` in RxJS
The lift method on each source hides away the internals of RxJS so you can simply connect a source t ...
- Phalcon 开发工具(Phalcon Developer Tools)
Phalcon提供的这个开发工具主要是用来辅助开发,比方生成一些程序的基本框架.生成控制器模型等. 使用这个工具我们仅仅须要一个简单的命令就可以生成应用的基本框架. 很重要: 要使用这个工具我们必需要 ...