Extracting with sed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Extracting with sed
# 1  
Old 02-05-2010
Extracting with sed

Hi all,

i have a log file which consits of the below text
Code:
SQL> @.[%OSAUTH_PREFIX_DOMAIN%]
SP2-0310: unable to open file ".[FALSE]"
SQL> spool off

From this file i need to extract the text from the second line in between [] (i.e) False and need to put this output to a another file...

How can i do this with SED command

Last edited by Yogesh Sawant; 02-05-2010 at 06:04 AM.. Reason: added code tags
# 2  
Old 02-05-2010
extracting with sed

Try

Code:
sed -e "s;.*\[\(.*\)\].*$;\1;g" yourlogfile.log > yourfilelist

HTH
JG


Your requirement changed so this won't work. Sorry!

Last edited by jgrogan; 02-05-2010 at 06:26 AM.. Reason: OP's requirement changed...
# 3  
Old 02-05-2010
Try this:
Code:
sed -n '/\]"$/s/.*\[\(.*\)\].*/\1/p' file > newfile

# 4  
Old 02-05-2010
This is not working
# 5  
Old 02-05-2010
Quote:
Originally Posted by mhdmehraj
This is not working
Works fine for me:

Code:
$ cat file
SQL> @.[%OSAUTH_PREFIX_DOMAIN%]
SP2-0310: unable to open file ".[FALSE]"
SQL> spool off
$
$ sed -n '/\]"$/s/.*\[\(.*\)\].*/\1/p' file
FALSE

# 6  
Old 02-05-2010
Code:
D:\bfx_db>sed -n '/\]"$/s/.*\[\(.*\)\].*/\1/p' test.sql > testout.sql
sed: -e expression #1, char 1: Unknown command: `''

We are Using sed on windows

Last edited by pludi; 02-05-2010 at 07:42 AM.. Reason: code tags, please...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed - extracting the first word only if match

Hello. from a text file, I want to get only the first word ( before blank ) following code= grep -i -e "WORD1" "/path/to/text/file.txt | sed -n 's/WORD1\+//p' | sed -n 's/code=/\1/p' return an error. sed: -e expression #1, char 12: invalid reference \1 on `s' command's RHSFor debugging... (12 Replies)
Discussion started by: jcdole
12 Replies

2. Shell Programming and Scripting

sed extracting numbers

I have number 192.168.21.8. I want to extract from this number with sed 21 and 8 to variables a and b. Any Ideas? I did like 's/\(192.168.\)/ /' but its wrong :( (6 Replies)
Discussion started by: Natalie
6 Replies

3. Shell Programming and Scripting

Extracting lines from a file with sed and awk

My source file is structured with two words on each line word1 word2 word1 word2 I am using sed and awk to grab groups of specific lines line=`awk 'NR>=4 && NR<=7' file1`; echo $line line=` sed -n '1,5'p file1`; echo $line The resulting output is word1 word2 word1 word2 word1... (1 Reply)
Discussion started by: bash_in_my_head
1 Replies

4. Shell Programming and Scripting

Problems extracting word using SED

I have a file containing strings such as: UPDATE PS_CA_BI_FF2_TA3 SET DELETE_ME = 'Y' WHERE PROCESS_INSTANCE BI.LAST_UPDATE_DTTM FROM PS_CA_BP_LINES LINE, PS_INTFC_BI BI WHERE EXISTS ( SELECT 'X' FROM PS_CA_BILL_PLAN BP WHERE BP.CONTRACT_NUM %Select(COUNTER4) SELECT COUNT(*) FROM PS_INTFC_BI... (2 Replies)
Discussion started by: simpletech369
2 Replies

5. Windows & DOS: Issues & Discussions

Extracting variables between commas : GAWK or SED

Hello, I need some help, I got a CSV file called test.txt with this text in it : 08/02/2011;0,677;0,903;1,079;1,336;1,513;1,683 There's only a line and i need to copy theese numbers into variables : 0,677 0,903 1,079 1,336 1,513 1,683 The output file should look like this... (5 Replies)
Discussion started by: jujulips
5 Replies

6. Shell Programming and Scripting

sed doubt in extracting

Hi, Can anyone help me in understanding how the below code works? echo "texxt" | sed 's///' gives output exxt, ideally it should give xxt. as this should remove the chars which is not x. echo 'x_a_b_a_c_a_d' | sed 's/.*\(a\)/\1/' gives output as a_d, which should be 'a' as it's the only... (2 Replies)
Discussion started by: royalibrahim
2 Replies

7. Shell Programming and Scripting

extracting matched pattern from a line using sed

I am trying to pull certain pieces of data out of a line of a file that matches a certain pattern: The three pieces that I want to pull out of this line are the only occurrences of that pattern within the line, but the rest of the line is not consistent in each file. Basically the line is... (3 Replies)
Discussion started by: ellhef
3 Replies

8. UNIX for Dummies Questions & Answers

Extracting Data Using SED

Given the following text in a file named extract.txt: listenPort:=25 smtpDestination:=2 enableSSL:= I am trying to extract only the value 2 following smtpDestination:= Someone had suggested I use: sed -e "s/^smtpDestination:=\(.*\)$/\1/" extract.txt but this returns: listenPort:=25 2 ... (2 Replies)
Discussion started by: cleanden
2 Replies

9. Shell Programming and Scripting

extracting XML file using sed

Hello folks I want to extract data between certain tag in XML file using 'sed' <xml> ......... .......... <one>XXXXXXXXXXXXXXXXXXXX</one> ...... Anyone ?Thank you (7 Replies)
Discussion started by: pujansrt
7 Replies

10. UNIX for Dummies Questions & Answers

Extracting the last 3 chars from a string using sed

Hi. Can I extract the last 3 characters from a given string using sed ? Why the following doesn't work (it prints the full string) : echo "abcd" | sed '/\.\.\.$/p' doesn't work ? output: abcd Thanks in advance, 435 Gavea. (7 Replies)
Discussion started by: 435 Gavea
7 Replies
Login or Register to Ask a Question