shell编程之tee命令和paste命令:数据输出命令

shell编程之tee命令和paste命令:数据输出命令

tee命令:双向输出命令

作用:双向输出

用途:多路径输出

tee命令说明:

命令格式:
	#L 命令 | tee 选项 filenema
		选项说明:
			-a:双向追加重定向
		
#l		注意:tee命令从标准输入读取并写入标准输出和文件,即:双向覆盖重定向<屏幕输出|文本输入>
		
			
演示:
	# echo "hello word"
		[root@server ~]# echo "hello word"
			hello word

	# echo "hello word" | tee 3.txt				=>	不加-a选项是覆盖输入,且会新建文件
		[root@server ~]# echo "hello word" | tee 3.txt
			hello word
		[root@server ~]# cat 3.txt
			hello word

	# echo "say goodbye" | tee 3.txt			=>	不加-a选项是覆盖输入,且会新建文件
		[root@server ~]# echo "say goodbye" | tee 3.txt
			say goodbye
	# cat 3.txt		
		[root@server ~]# cat 3.txt
			say goodbye

	# echo "hello word" | tee -a 3.txt			=>-a选项则追加输入
		[root@server ~]# echo "hello word" | tee -a 3.txt
			hello word
		[root@server ~]# cat 3.txt
			say goodbye
			hello word

paste命令:多文件合并输出命令

作用:多文件打印输出(内存中处理)

用途:多文件数据合并处理

paste命令说明:

命令格式:
	# paste 选项 选项的值 filename1 filename2..
		选项说明:	
			-d:自定义分割符。默认分割符是tab键
			-s:串行处理,非并行
#l		备注:默认将多个文件并行输出


演示:
	# paste 1.txt 2.txt			=>	两个文件合并输出,默认分割符为tab键
		[root@server ~]# paste 1.txt 2.txt
			a       1
			b       2
			c       3
			d       4
			        5

	# paste -d '-' 1.txt 2.txt		=>	两个文件合并输出,-d 指定分隔符为"-"
		[root@server ~]# paste -d '-' 1.txt 2.txt
			a-1
			b-2
			c-3
			d-4
			-5

	# paste  -s 1.txt 2.txt			=>	-s 指定两个文件串行输出,默认分隔符tab键
		[root@server ~]# paste  -s 1.txt 2.txt
			a       b       c       d
			1       2       3       4       5
	
	# paste -d '-' -s 1.txt 2.txt	=>	-s 指定两个文件串行输出,-d 指定分割符为"-"
		[root@server ~]# paste -d '-' -s 1.txt 2.txt
			a-b-c-d
			1-2-3-4-5
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值