cat -n

You can use the cat command concatenate files and show on the screen under Linux or Unix like operating systems. The cat command also number all output lines starting with number one with the following syntax:

cat -n fileNameHere

OR

cat --number foo.c

The -b / --number-nonblank option number all nonempty output lines, starting with one and the syntax is:

cat -b fileNameHere

OR

cat --number--nonblank filename

Finally, you suppress or remove repeated empty output lines with the -s / --squeeze-blank option:
cat -s -n fileNameHere

OR

cat --squeeze-blank -n filename

Say hello to nl command

Use the nl command number lines of files under Linux or Unix oses. The syntax is:

nl filename

Examples

Create a text file called hello.c as follows:

/* Purpose: Sample see program to print Hello world on stdout 
 * Author: nixCraft
 * Copyright: None / Copyleft
 */
 
#include<stdio.h>
 
/* our main */
int main(void){
	printf("Hello world\n");
	return 0;
}

Use the cat or nl command to display line numbers:

cat -n hello.c
nl hello.c

Sample outputs:

Fig.01: Displaying line numbers for hello.c using the cat and nl command.

Fig.01: Displaying line numbers for hello.c using the cat and nl command.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值