[英]how to merge/append one file content to another file using shell script
I have two file fileA and fileB我有两个文件 fileA 和 fileB
FileA
content FileA
内容
PersonName Value1 Value2 Value3
FileB
content FileB
内容
ALBERT check1 check1 check1
ALBERT check2 check2 check2
ALBERT check3 check3 check3
I want to merge content of fileA and fileB and FileA content should be the first line in the merged file我想合并 fileA 和 fileB 的内容,并且 FileA 内容应该是合并文件的第一行
I tried using paste
and sort
command... not not able to get required result any suggestions...我尝试使用paste
和sort
命令...无法获得所需的结果任何建议...
cat FileA FileB > NewFile
or或者
cat FileA > NewFile
cat FileB >> NewFile
In Unix/Linux you can use the command cat在 Unix/Linux 中,您可以使用命令 cat
Example:例子:
cat file1.txt file2.txt > file3.txt
This will put the contents of file1 and file2 into file3.这会将file1和file2的内容放入file3中。
cat file1.txt >> file2.txt
This will add the information from file1.txt to the information already existing in file2.txt这会将 file1.txt 中的信息添加到 file2.txt 中已经存在的信息中
cat FileA | tee -a FileB
$ cat FileA
PersonName Value1 Value2 Value3
$ cat FileB
ALBERT check1 check1 check1
ALBERT check2 check2 check2
ALBERT check3 check3 check3
$ cat FileA | tee -a FileB
ALBERT check1 check1 check1
ALBERT check2 check2 check2
ALBERT check3 check3 check3
PersonName Value1 Value2 Value3
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.