二個文件合併

[root@centos tmp]# cat host-ip.sh
#!/bin/bash
usage()
{
echo "$0 file1 file2"
exit 1;
}
if [ $# -ne 2 ];then
usage;
else
paste $1 $2 >temp;
sed -i 's/\t/</g' temp;
sed -i 's/$/>/g' temp;
mv temp host-ip.out;
fi


[root@centos tmp]# 

[root@centos tmp]# cat host 
cnsz01
cnsz02
cnsz03
cnsz04
cnsz05
cnsz06
cnsz07
cnsz08
cnsz09
cnsz10
cnsz11

[root@centos tmp]# cat ip
192.168.0.1
192.168.0.2
192.168.0.3
192.168.0.4
192.168.0.5
192.168.0.6
192.168.0.7
192.168.0.8
192.168.0.9
192.168.0.10
192.168.0.11

[root@centos tmp]# cat host-ip.out
cnsz01<192.168.0.1>
cnsz02<192.168.0.2>
cnsz03<192.168.0.3>
cnsz04<192.168.0.4>
cnsz05<192.168.0.5>
cnsz06<192.168.0.6>
cnsz07<192.168.0.7>
cnsz08<192.168.0.8>
cnsz09<192.168.0.9>
cnsz10<192.168.0.10>
cnsz11<192.168.0.11>
<>
[root@centos tmp]# 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章