copy some text from one file to another
I have a text file, in that some text is there seperated by "$" sign.
suppose file name is ash.txt and in that some text like abcde$ghijk$lmnop$qrst . now I want to make new files as ash1.txt,ash2.txt and so on.... In that different text will be there which was sepetated by "$" sign. Like in ash1.txt there should be "abcde" and in ash2.txt there should be "ghijkl" and so on..... Pls help me to do this |
Hi,
I think this can be done with a one-liner: awk 'BEGIN { FS="" ; RS="$" ; i=1 } {print $0 > "ash"i".txt" } { i++ }' infile01 There is one minor shortcoming: The last file that is created also has an extra empty line. Example: Code:
$ cat infile01 |
Copying file to another file
Hey,
m a new user in linux. I wonder how I can copy some contents from a file in a different directory to another file in another directory without overwriting the previous contents in the new file I want to paste my contents in question. Any suggestion would be very appreciated. |
Using a double pipe sign will append the contents from the first file to the second. This is the sign: >>
Code:
file1 >> /home/user/file2 |
Hi,
Quote:
Mark1986 gave a partial answer, but not a complete one.... If you want to append the contents of a file to another file you indeed need a double redirect (>>). A single one will overwrite a double one will append. But you also need a command that tells the system what to do with a file (Mark1986's example won't work, due to this). cat is a commonly used command to do so: cat file1 >> /location/of/file2 Hope this helps. |
Quote:
|
Thank u guys... I get...it was helpful, and I had to make it easier by copying the file in the same directory and then append the file easily...
|
You're welcome :)
|
All times are GMT -5. The time now is 06:57 AM. |