Sponsored Content
Top Forums Shell Programming and Scripting single line input to multiple line output with sed Post 302214687 by radoulov on Monday 14th of July 2008 04:27:14 PM
Old 07-14-2008
Without the entire code it would be difficult to debug,
try copy/pasting the code (there is an escaped new line):

Code:
zsh-4.3.4% cat file
TCF_Distro,10.10.50.2,WS-C3560-24TS,CAT1050RH3D,AHA,10.10.50.3,WS-C3560-24TS,CAT1050RHT2,TCF,10.10.50.4,WS-C3560-48PS,CAT1026RKD3
zsh-4.3.4% sed 's/\([^,]*,\)\{4\}/&\
quote> /g' file
TCF_Distro,10.10.50.2,WS-C3560-24TS,CAT1050RH3D,
AHA,10.10.50.3,WS-C3560-24TS,CAT1050RHT2,
TCF,10.10.50.4,WS-C3560-48PS,CAT1026RKD3

With GNU sed you could even write it like this:

Code:
zsh-4.3.4% sed -r 's/([^,]*,){4}/&\n/g' file
TCF_Distro,10.10.50.2,WS-C3560-24TS,CAT1050RH3D,
AHA,10.10.50.3,WS-C3560-24TS,CAT1050RHT2,
TCF,10.10.50.4,WS-C3560-48PS,CAT1026RKD3

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

make multiple line containing a pattern into single line

I have the following data file. zz=aa azxc-1234 aa=aa zz=bb azxc-1234 bb=bb zz=cc azxc-1234 cc=cc zz=dd azxc-2345 dd=dd zz=ee azxc-2345 ee=ee zz=ff azxc-3456 ff=ff zz=gg azxc-4567 gg=gg zz=hh azxc-4567 hh=hh zz=ii azxc-4567 ii=ii I want to make 2nd field pattern matching multiple lines... (13 Replies)
Discussion started by: VTAWKVT
13 Replies

2. Shell Programming and Scripting

Putting multiple sed commands on a single line

Hi, I want to make sed write a part of fileA (first 7 lines) to file1 and the rest of fileA to file2 in a single call and single line in sed. If I do the following: sed '1,7w file1; 8,$w file2' fileA I get only one file named file1 plus all the characters following file1. If I try to use curly... (1 Reply)
Discussion started by: varelg
1 Replies

3. Shell Programming and Scripting

SED - Multiple String - Single Line

Would appear to me to be a farily simple question but having search all the threads I can't find the answer .. I just want sed to output the single line in a file that contains two string anywhere on the line.. e.g. currently using this command sed -n -e'/str1/p' -e '/str2/p' < file and... (3 Replies)
Discussion started by: flopster
3 Replies

4. Shell Programming and Scripting

Two Input Lines Into Single Output Line (CSV)

Hi all, My search karate must be weak because I'm about certain something very like this has been asked and answered here many times. I'll give you the exact scenario I've wasted a few hours of my Saturday on: :wall: I'm trying to read through a very large number (~200) of router and... (28 Replies)
Discussion started by: svermill
28 Replies

5. Shell Programming and Scripting

Merge multi-line output into a single line

Hello I did do a search and the past threads doesn't really solve my issue. (using various awk commands) I need to combine the output from java -version into 1 line, but I am having difficulties. When you exec java -version, you get: java version "1.5.0_06" Java(TM) 2 Runtime... (5 Replies)
Discussion started by: flagman5
5 Replies

6. Shell Programming and Scripting

Joining multi-line output to a single line in a group

Hi, My Oracle query is returing below o/p ---------------------------------------------------------- Ins trnas value a lkp1 x a lkp1 y b lkp1 a b lkp2 x b lkp2 y ... (7 Replies)
Discussion started by: gvk25
7 Replies

7. Shell Programming and Scripting

convert single line output to multiple line

Hi all, I have a single line output like below echo $ips 10.26.208.28 10.26.208.26 10.26.208.27 want to convert above single line output as below format. Pls advice how to do ? 10.26.208.28 10.26.208.26 10.26.208.27 Regards Kannan (6 Replies)
Discussion started by: kamauv234
6 Replies

8. Shell Programming and Scripting

sed command to grep multiple pattern present in single line and delete that line

here is what i want to achieve.. i have a file with below contents cat fileName blah blah blah . .DROP this REJECT that . --sport 7800 -j REJECT --reject-with icmp-port-unreachable --dport 7800 -j REJECT --reject-with icmp-port-unreachable . . . more blah blah blah --dport 3306... (14 Replies)
Discussion started by: vivek d r
14 Replies

9. Shell Programming and Scripting

Multiple pattern match and print the output in a single line

I need to match two patterns in a log file and need to get the next line of the one of the pattern (out of two patterns) that is matched, finally need to print these three values in a single line. Sample Log: 2013/06/11 14:29:04 <0999> (725102) Processing batch 02_1231324 2013/06/11... (4 Replies)
Discussion started by: rpm120
4 Replies

10. UNIX for Beginners Questions & Answers

Output to file print as single line, not separate line

example of problem: when I echo "$e" >> /home/cogiz/file.txt result prints to file as:AA BB CC I need it to save to file as this:AA BB CC I know it's probably something really simple but any help would be greatly appreciated. Thank You. Cogiz (7 Replies)
Discussion started by: cogiz
7 Replies
COLORMGR(1)															       COLORMGR(1)

NAME
colormgr - Color Manager Testing Tool SYNOPSIS
colormgr [ --verbose ] DESCRIPTION
This manual page documents briefly the colormgr command. colormgr allows an administrator to view and change color profile to device mappings. OPTIONS
This program follows the usual GNU command line syntax, with long options starting with two dashes (`-'). A summary of options is included below. --help Show summary of options. COMMANDS
This program takes commands with a variable number of arguments. create-device Creates a color managed device create-profile Create a color profile delete-device Deletes a color managed device delete-profile Deletes a color profile device-add-profile Add a profile to a device that already exists device-get-default-profile Gets the default color profile for a device device-get-profile-for-qualifier Returns all the profiles that match a given qualifier device-make-profile-default Makes a profile default for a specific device device-set-kind Sets the device kind device-set-model Sets the device model device-set-serial Sets the device serial device-set-vendor Sets the device vendor find-device Find a device from the device ID find-device-by-property Find a device with a given property value find-profile Find a profile from the profile ID find-profile-by-filename Find a profile from the filename get-devices Gets all the color managed devices get-devices-by-kind Gets all the color managed devices of a specific kind get-profiles Gets all the available color profiles profile-set-filename Sets the profile filename profile-set-qualifier Sets the profile qualifier AUTHOR
This manual page was written by Richard Hughes <richard@hughsie.com>. 20 December,2008 COLORMGR(1)
All times are GMT -4. The time now is 06:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy