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

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

tr command : convert lines to tab

Use the below given command.

tr 'n' 't' < /tmp/test

Below is the output screenshot.
tr command

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.

tr command

Read Some More Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.