Joining lines of text on Linux
Thursday, 9 February 2023
Add Comment
There are number of ways to join multiple lines of text and change delimiters if needed. This article shows two of the easier ways to do this and explains the commands.
Using the tr command
The tr command is quite versatile. It’s used to make many types of changes to text files, but it can also flatten multiple lines into one by replacing newline characters with blanks. It does, however, remove the final newline as well. Note the $ prompt at the end of the second line. That's a clue!
$ tr '\n' ' ' < testfile This is a file that I can use for testing. $ $ tr '\n' ' ' < testfile > newfile
To fix this problem, you can add a newline to the end of the file with an echo command like this:
from Network World https://ift.tt/9oEibw4
Genrerating Link.... 15 seconds.
Your Link is Ready.
0 Response to "Joining lines of text on Linux"
Post a Comment