sed should cut of everything include the brackets


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sed should cut of everything include the brackets
# 1  
Old 05-18-2012
sed should cut of everything include the brackets

Hi there!

sed should cut of everything include the brackets
... 443,0.806362,0.67317,1.46563,14.8237(#/cm�)
... 5112,0.812411,0.67317,1.4831,14.1875(#/cm�)

it should be
... 443,0.806362,0.67317,1.46563,14.8237
... 5112,0.812411,0.67317,1.4831,14.1875

i try it several times with ...
Code:
sed 's/\[(*)\]//' TURM052012_sed.txt

It will not work, i think the reason is the . I thought the * will catch every charcter.
Can you please help me?

Thanks in advance!
IMPe
# 2  
Old 05-18-2012
* will match any number (0 or more) of the previously matched character

Code:
$ sed "s/([^)]*)//" file
... 443,0.806362,0.67317,1.46563,14.8237
... 5112,0.812411,0.67317,1.4831,14.1875

# 3  
Old 05-18-2012
Hi Scott!

Thank you for helping me, but unfortunatelly it is not working- everything (#/cm�) is still there.

Quote:
Originally Posted by Scott
* will match any number (0 or more) of the previously matched character

Code:
$ sed "s/([^)]*)//" file
... 443,0.806362,0.67317,1.46563,14.8237
... 5112,0.812411,0.67317,1.4831,14.1875

also the additional modifier g will bring any change.
Code:
 sed "s/([^)]*)//g" file

Thanks!
IMPe

Last edited by IMPe; 05-18-2012 at 06:32 AM..
# 4  
Old 05-18-2012
Then it might be the funny character. Also know that the sed is not updating the file, it's just printing to the screen, so if you're xpecting the file to be updated, it's not.

Is the input you showed actual input or "example" input?

If it's actual, then there you have various other options:
Code:
sed "s/(.*//"
sed "s/\(.*\)(/.*\1/"
awk -F\( '{print $1}'
cut -d\( -f1

This User Gave Thanks to Scott For This Post:
# 5  
Old 05-18-2012
Quote:
Originally Posted by Scott
Then it might be the funny character. Also know that the sed is not updating the file, it's just printing to the screen, so if you're xpecting the file to be updated, it's not.

Is the input you showed actual input or "example" input?

If it's actual, then there you have various other options:
Code:
sed "s/(.*//"
sed "s/\(.*\)(/.*\1/"
awk -F\( '{print $1}'
cut -d\( -f1

Hi Scott!

Thank you!
Code:
awk -F\( '{print $1}'
cut -d\( -f1

these both command are working fine, but i dont get successful with the sed-commands. However -
Code:
awk -F\( '{print $1}'

is my favorit, because its easy and smartish - and for the only bracket in the row the accurate remedy.
Thanks a lot.
IMPe
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Need help with sed replace script to include spaces

I've got a sed shell script I've been using for quite a while to do batch find/replace operations on .xml files containing various types of text entries. This is the script I use: #!/bin/bash while read text_old text_new; do sed_script+="s/$text_old/$text_new/g;" done < trans_old_to_new... (9 Replies)
Discussion started by: Agreppa
9 Replies

2. Homework & Coursework Questions

Sed, matching nested brackets and deleting

1. The problem statement, all variables and given/known data: I have to write a script using sed, which delete everything between curly brackets and the brackets themself. The brackets might be nested. The input-file is: aaa { bbb ccc { ddd eee } fff { ... (2 Replies)
Discussion started by: FuzzyGnome
2 Replies

3. Shell Programming and Scripting

Adding a backslash in front of square brackets with sed

I'm trying to convert this line: to \ with sed. This is what I have so far: sed -e 's/\]*\)\]/\\\\\/' but this still gives me . Any suggestions? (15 Replies)
Discussion started by: lehaste
15 Replies

4. Shell Programming and Scripting

How can I get sed to include backslash and 'f' in the output

Both of these fail. One has two form feeds, the second form leaves all the backslashes. bold='\(code\|command\|var\|samp\|option\|strong\)' sed -e "s;@${bold}{"'\(*\)};\fB\2\fP;g' sed -e "s;@${bold}{"'\(*\)};\\fB\2\\fP;g' Obviously, I'm trying to change texi markup into man page markup, but it... (3 Replies)
Discussion started by: bkorb
3 Replies

5. Shell Programming and Scripting

my sed how to include my sftp command!

Hi All, I'm a newbie here, i'm just wondering how can i include my sftp command, here is my code. see below. test -f /home/1.txt && sed -i "s/$/&,pogi" /home/1.txt my sftp command: how can i insert my sftp command in my code above? sftp ${USER}@${HOST} <<-EOF cd ${INPUT_DONE} ... (0 Replies)
Discussion started by: nikki1200
0 Replies

6. Shell Programming and Scripting

Delete text between square brackets and also delete those square brackets using sed or awk

Hi All, I have a text file which looks like this: computer programming systems engineering I want to get rid of these square brackets and also the text that is inside these brackets. So that my final text file looks like this: computer programming systems engineering I am using... (3 Replies)
Discussion started by: shoaibjameel123
3 Replies

7. Shell Programming and Scripting

strip the square brackets from a word using sed or var expansion

Hi, I am trying to strip out leading and trailing brackets from a word. for example, I have a value, in a file. I want to strip out the leading and trailing brackets it and should get the value Running. I am using the following statement but in vain. grep "Workflow run status:" <... (4 Replies)
Discussion started by: svajhala
4 Replies

8. Shell Programming and Scripting

Include white spaces while using CUT command

Hi I tried to extract 19 characters (default) enclosed with in tag from a file using cut command. If the characters comprises of double space, the cut command gives the output with a single spacing. file 1 <name>Kumar Rajasekaran</name> cut -c7-26 "file1" the out put i received is ... (48 Replies)
Discussion started by: Sekar1
48 Replies

9. Shell Programming and Scripting

Include Line Before Pattern Using Sed / Awk

Hi, I have a sql file that runs something like this vi Test.sql REVOKE EXECUTE ON DEMO_USER.SQC_SAMP FROM PUBLIC; REVOKE EXECUTE ON DEMO_USER.SQC_SAMP FROM DEMO_READ; REVOKE SELECT ON DEMO_USER.DEMO_NOMINEE_TEST FROM DEMO_READ; REVOKE EXECUTE ON DEMO_USER.SQC_SAMP FROM... (3 Replies)
Discussion started by: rajan_san
3 Replies

10. Shell Programming and Scripting

cut but include delimiter at end

Can someone please tell me how to do this... input file - /etc/group: wheel:*:0:root,timber daemon:*:1: mysql:*:88: ...etc... giants:*:1001:dalton,bandit dalton:*:1002: bandit:*:1003: output file (my goal): giants:*:1001: dalton:*:1002: bandit:*:1003:I've come up with this: ... (3 Replies)
Discussion started by: Lewcifer
3 Replies
Login or Register to Ask a Question