Reputation: 11
I have a text file like inputfolder/abc.txt
Input (Below is just an example - the actual file will have many lines which will vary everytime):
abcdefgh~
asdfghjkliuy~
qwertyuiopasdfgh~
..........
Every line ends with '~' and I would like to merge all the lines into one
Desired output:
abcdefgh~asdfghjkliuy~qwertyuiopasdfgh~...............
How can I merge all the lines into one line using shell script? (I don't want to add any extra character)
Once all the lines are merged, the file should be moved to another folder.
Example: OutputFolder/abc.txt
Upvotes: 0
Views: 2560
Reputation: 3115
You can solve this with tr
and the delete parameter (delete the new line characters).
$ cat inputfolder/abc.txt
abcdefgh~
asdfghjkliuy~
qwertyuiopasdfgh~
..........
$ cat inputfolder/abc.txt | tr -d "\r\n" > outputFolder/abc.txt
$ cat outputFolder/abc.txt
abcdefgh~asdfghjkliuy~qwertyuiopasdfgh~..........
Or with sed
:
$ sed -z "s/\n//g" inputfolder/abc.txt > outputFolder/abc.txt
Upvotes: 1