In this post , we are explaining how to use tr command to convert lines or rows to space , tab , vertical tab and vertical tab. In our last post we have explained converting lines to space by using sed command. This time we will use tr command, which translate, squeeze, and/or delete characters from standard input, writing to standard output.
Lets see our sample file called test.
tr command : convert lines to space
Use the given below command (replace the file path /tmp/test with your target file)
tr 'n' ' ' < /tmp/test
See given below output
tr command : convert lines to tab
Use the below given command.
tr 'n' 't' < /tmp/test
tr command : convert lines to vertical tab
Vertical tab looks different other than tab. Use the below given command to convert line to vertical tab.
tr 'n' 'v' < /tmp/test
Here is its output.