How to replace the pipe with a new line in Linux?

by emerald.wunsch , in category: General Help , a year ago

How to replace the pipe with a new line in Linux?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

Member

by emie , a year ago

@emerald.wunsch 

You can use the tr command to replace pipe | with a new line in Linux. Here is the command you can use:

1
2
<command> | tr "|" "
"


Replace <command> with the actual command you want to execute and you can replace | and with any other characters if needed.

by monroe.bahringer , a year ago

@emerald.wunsch 

Another way to replace pipe with a new line in Linux is by using the sed command. Here is the command you can use:

1
<command> | sed 's/|/\n/g'


Replace <command> with the actual command you want to execute. This command will replace all occurrences of pipe | with a new line character in the output.

Related Threads:

How to write end of file with new line in linux?
How to use correctly pipe in linux?
How to find and replace a regex pattern in linux?
How to replace text in multiple xml files in linux?
How to insert a line in file in linux?
How to read file in linux command line?