Tuesday, December 11, 2012

Put a.txt -file to the end of b.txt -file

In a bash script such append.sh file, write the following code: 
#!/bin/bash
A=/root/tmp/test/a.txt
B=/root/tmp/test/b.txt
cat $A >> $B


The >> redirects the output of the cat command (which output file A) to the file B. But instead of overwriting contents of B, it appends to it. If you use a single >, it will instead overwrite any previous content in B.

No comments:

Post a Comment