Removing spaces between parenthesis ()


Login or Register to Reply

 
Thread Tools Search this Thread
# 15  
Old 1 Week Ago
Quote:
Originally Posted by Don Cragun
Hi johnprogrammer,
Welcome to the UNIX and Linux forums.

Thank you.

Quote:
Note that the problem being addressed in this thread didn't say anything about only wanting to remove spaces between parentheses on lines that also contain the string "httpd".

Note that the problem being addressed in this thread didn't say anything about only wanting to remove a single space between parentheses.

Note that the problem being addressed in this thread didn't say anything about only wanting to remove spaces between parentheses only lines that have exactly one <space> before the first parenthesis on that line.

Those were what I understood.

Quote:
Note that the problem being addressed in this thread didn't say anything about removing lines that do not contain spaces between parentheses.

Yes, I knew that, but I considered my answer as a good starting point.

Quote:
Please be careful about saying that your code works when it looks like the code that you have provided makes several assumptions that do not seem to match the requirements being addressed in this thread.

This is important, and you are right. I thought a few times to edit the post, and write: "I think this should work". But unfortunately I didn't. Sorry.

Last edited by johnprogrammer; 1 Week Ago at 01:37 AM..
# 16  
Old 1 Week Ago
Quote:
Originally Posted by RudiC
Can there be more than one space between the parentheses that have to be removed?
Is the position of the last field to be retained?

EDIT: howsoever, try
Code:
sed  ':L; s/\(([^ )]*\) \([^)]*)\)/\1\2 /; tL' file

Unix sed does not end a lable at a semicolon, needs a boundary:
Code:
sed  '
 :L
 s/\(([^ )]*\) \([^)]*)\)/\1\2 /
 tL
' file

or
Code:
sed  -e ':L' -e 's/\(([^ )]*\) \([^)]*)\)/\1\2 /; tL' file

And of course it does not take -r and ERE.
This User Gave Thanks to MadeInGermany For This Post:
RudiC (1 Week Ago)
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Removing blanks, spaces sususa Shell Programming and Scripting 5 07-03-2012 03:57 AM
Removing blank spaces rogerben Solaris 6 01-30-2012 02:30 AM
awk for removing spaces shruthidwh Shell Programming and Scripting 4 05-16-2011 12:25 PM
removing spaces in filenames ianebaj Shell Programming and Scripting 4 11-05-2010 02:32 AM
Removing spaces from record raghavendra.cse Shell Programming and Scripting 3 04-08-2010 07:27 AM
Removing spaces within Filename Fishn Shell Programming and Scripting 7 10-21-2009 12:21 PM
Removing spaces in a line krishna_gnv Shell Programming and Scripting 2 09-20-2009 10:20 PM
Removing blank spaces, tab spaces from file NARESH1302 Shell Programming and Scripting 3 08-07-2009 11:18 AM
Removing spaces from string ippy98 Shell Programming and Scripting 7 03-18-2009 11:10 PM
Removing spaces from data monika Shell Programming and Scripting 4 11-09-2008 03:34 PM
Removing spaces... lost UNIX for Dummies Questions & Answers 2 10-06-2008 05:46 PM
removing spaces sahithi_khushi Shell Programming and Scripting 2 11-03-2006 10:20 AM
Removing spaces at particular position superprogrammer Shell Programming and Scripting 7 07-10-2006 05:29 AM
removing spaces after sperator vishnu_vaka Shell Programming and Scripting 6 03-24-2006 09:17 AM
Removing spaces between records thanuman UNIX for Dummies Questions & Answers 6 11-17-2005 12:01 PM