cat命令

本文介绍了如何使用cat命令来压缩文本文件中的多个空白行为单个空白行,并展示了如何显示文件中的制表符。此外,还演示了如何利用cat命令结合tr命令来进一步处理文本,包括移除空白行等技巧。

#cat file1 file2 file3 ...

#cat file.txt

1 2 3

压缩空白行(将文本中多个空白行压缩为单个)

#cat -s file   (压缩连续的空白行)

#cat -s file | tr -s '\n'    也可以用tr移除空白行  (将多个空白行压缩为单个)

显示制表符

#cat -T file

输出行号

#cat -n file

1    txt

2    txt

3    txt


在cat << EOF>file.tst与下一个EOF行之间的所有文本都会被当作stdin数据

#!/bin/bash

cat <<EOF>file.txt

this is a test file

this is a test file

this is a test file

EOF


#cat file.txt

this is a test file

this is a test file

this is a test file


转载于:https://my.oschina.net/MrYx3en/blog/213510

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值