Copy the contents of a txt file to other txt files (with similar names) by cp command
Code:
cp -r aa123.h aa*.h Code:
cp: target `aa456.h' is not a directory Kindly guide. |
Quote:
|
Quote:
Just tried it without -r, same error repeats. |
cp cannot be used to add text to another file.
The cat command should be used. cat = Concatenate http://publib.boulder.ibm.com/infoce.../rzahz/cat.htm http://www.linfo.org/cat.html Say you do 'cp -f aa123.h aa456.h' : aa456.h will disappear / be replaced by aa123.h ..... |
This might work (try at your own risk).
Code:
cat aa123.h >> aa*.h |
Hi,
Quote:
This works: for THISFILE in aa*.h; do cat aa123.h >> $THISFILE; done But be careful! aa*.h will also include aa123.h. In the above on-liner it will be picked up (cat: aa123.h: input file is output file), but depending on what commands you use, you could end up with an empty file. Hope this helps. |
Quote:
Code:
aa123.h aa456.h aa789.h Code:
cp aa123.h aa*.h Code:
cp aa123.h aa123.h aa456.h aa789.h Not to mension that two of the source files are the same. |
You could use a small script to make sure you don't loose the original file
Code:
cp aa123.h temp |
All times are GMT -5. The time now is 06:19 PM. |