gnu sed replace space with new line

Login or Register for Dates, Times and to Reply

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting gnu sed replace space with new line
# 1  
gnu sed replace space with new line

please help in making sed singleline command
i need to insert dos new line (CR LF) before
" 34 matching device(s) found on \\cpu1."
" 6 matching device(s) found on \\cpu7."
" 102 matching device(s) found on \\mainserver."
the problem is that sometimes there are both CR LF before strings and sometimes they are missing:
PCI\VEN_10EC&DEV_8139&SUBSYS_E0001458&REV_10\3&61AAA01&0&78 : Realtek RTL8139/810X Family PCI Fast Ethernet NIC
34 matching device(s) found on \\cpu1.
PCI\VEN_8086&DEV_2561&SUBSYS_00000000&REV_03\3&13C0B0C5&0&08: Intel(R) 82845G/GL/GE/PE/GV/E CPU - AGP 36 matching device(s) found on \\cpu2.
PCI\VEN_8086&DEV_29C3&SUBSYS_82B01043&REV_02\3&11583659&0&11: Intel(R) G35/G31 Express Chipset Family
46 matching device(s) found on \\cpu10.

in other worlds, if in the middle of string there is "_here_comes_number_ matching device(s)" repace space before _here_comes_number_ with CR LF dos newline

windows 2k/xp, GNU sed version 4.1.5
# 2  

sed is great, here is the solution
sed "s/\(.*\) \(.* matching \)/\1\r\n\2/"

gnu sed winxp
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #967
Difficulty: Medium
The 'video' and 'audio' elements for multimedia content were deprecated in HTML5.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace space with !@ using sed

Hello I have a requirement where I need to replace space :61 with !@ :61 Source :60F:123 :61:151 :61:151 :61:15101 Target :60F:123 :61:151!@:61:151!@:61:15101 I cant use and command as I don't want the tab to be converted . commands not working : sed 's/... (5 Replies)
Discussion started by: kamijia83
5 Replies

2. UNIX for Dummies Questions & Answers

Sed- Replace space in filename by a \

`echo $file | sed 's/ / /g'` Hey guys I want help in converting the spaces in my file names to '\ ' . Example: UK maps --> UK\ maps Could someone please help me. I have tried the following sequences already (none of them work): 1)s/ /\ /g 2)s/ /\\ /g 3)s/ /\\\ /g Can someone... (7 Replies)
Discussion started by: INNSAV1
7 Replies

3. Shell Programming and Scripting

sed the find the third , and replace with a space

Dear All, I am new here. Could anyone help to find a sed script for replace the third "," to " "? input: abc,def,ghi,jkl,mno,pqr,stu,vxz output: abc,def,ghi jkl,mno,pqr,stu,vxz Many thanks. Please use code tags next time for your code and data. (2 Replies)
Discussion started by: mimilaw
2 Replies

4. Shell Programming and Scripting

SED - insert space at the beginning of line and multi replace command

hi I am trying to use SED to replace the line matching a pattern using the command sed 'pattern c\ new line ' <file1 >file 2 I got two questions 1. how do I insert a blank space at the beginning of new line? 2. how do I use this command to execute multiple command using the -e... (5 Replies)
Discussion started by: piynik
5 Replies

5. Shell Programming and Scripting

replace space with the help of sed

Hi, i have below string - mynameis arpit i want output like below - mynameis\ arpit that i am getting from below - temp='mynameis arpit' echo $temp|sed 's//\\ /g' --> mynameis\ arpit now i am doing - (2 Replies)
Discussion started by: thearpit
2 Replies

6. Shell Programming and Scripting

sed : replace space and end-of-line

Hi ! I'm rather new with sed ... learned a lot already by googling etc ... The following script should replace all spaces and ends-of-lines with "something (see below). #!/bin/bash i=0 while read line do fam="H`printf "%06d" $i`" echo $line | sed -e 's//\t'$fam'\n/g' i=$(($i+1))... (7 Replies)
Discussion started by: jossojjos
7 Replies

7. Shell Programming and Scripting

Replace 2 Occurances of Space (sed)

I have a large file that looks like the below output: system SUNWxwmod X Window System kernel modules system SUNWxwoft X Window System optional fonts system SUNWxwopt X Window System Optional Clients system ... (1 Reply)
Discussion started by: hxman
1 Replies

8. UNIX and Linux Applications

GNU sed - Search and Replace problem

Hi, The following code loops through every file with an error extension and then loops through all XML files in that directory and replaces the target character @ with / . The problem I have is that if there is more than one occurance of @ in each individual file it doesn't replace it. Any... (2 Replies)
Discussion started by: Fishn
2 Replies

9. Shell Programming and Scripting

how to replace new line ( \n ) with space or Tab in Sed

Hi, how to replace new line with tab in sed ... i used sed -e 's/\n/\t/g' <filename > but its not working (1 Reply)
Discussion started by: mail2sant
1 Replies

10. Shell Programming and Scripting

Replace space, that is not in html tags <> with new line using sed

Hi, I am working on transforming html code text into the .vert text format. I want to use linux utility sed. I have this regexp which should do the work: s/ \(?!*>\)/\n/g. I use it like this with sed: echo "you <we try> there" | sed 's/ \(?!*>\)/\n/g' ... The demanded output should be: you <we... (5 Replies)
Discussion started by: matt1311
5 Replies

Featured Tech Videos