Skip to content
Advertisement

How to convert multiple words in single line separated by comma in list of multiple lines

I have below text in file txt file as in below format

["Dell Inc.", "192.168.101.134", "44:a8:42:27:c7:ba", "PowerEdge R630", "6P84N62", "8", "Intel(R) Xeon(R) CPU E5-2623 v3 @ 3.00GHz", "32059.66", "172.16.100.21"]

but i need this as below format how do i format in linux

Dell Inc. 
192.168.101.134
44:a8:42:27:c7:ba
PowerEdge R630 
6P84N62
8 
Intel(R) Xeon(R) CPU E5-2623 v3 @ 3.00GHz
32059.66
172.16.100.21

Advertisement

Answer

echo "your string" |tr [ ' '|tr ] ' '|tr , \n|awk '{$1=$1};1'

Explanation

  • echo "your string" prints your string, then piped to the next tr
  • tr [ ' ' substitutes [ with an empty space
  • tr ] ' ' substitutes ] with an empty space
  • tr , \n substitutes the comma with a newline
  • awk '{$1=$1};1' (taken from here) trims spaces
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement