Dont what this sed expression does


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Dont what this sed expression does
# 1  
Old 12-06-2009
Question Dont what this sed expression does

I am new to unix and have come across the sed expression but not sure what its doing. Can someone please tell me whats happening in the sed command below?

Quote:
abc(){

sed "/debug=\"false\"/{x;N;s/.*/threshold=\"$1\"/;x;G;}" testFile.xml > testFileNew.xml
mv testFileNew.xml testFile.xml
}

abc $1
# 2  
Old 12-07-2009
man sed, please

Code:
      g G    Copy/append hold space to pattern space.

       x      Exchange the contents of the hold and pattern spaces.

      s/regexp/replacement/
              Attempt to match regexp against the pattern space.  If  success-
              ful,   replace  that  portion  matched  with  replacement.   The
              replacement may contain the special character & to refer to that
              portion  of  the  pattern  space  which matched, and the special
              escapes \1 through \9 to refer  to  the  corresponding  matching
              sub-expressions in the regexp.
      n N    Read/append the next line of input into the pattern space.

# 3  
Old 12-08-2009
Break the sed statement

I was wondering if we can break the sed command into two or more sets of command. What I mean is that rather than having everything in one line we can have

sed ...

sed...

sed ..

Can anyone help ?

---------- Post updated at 04:25 PM ---------- Previous update was at 10:17 AM ----------

Can anyone help me with my previous comment ?
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed regular expression

Hi , I need to remove pipe character from a |^ delimeted file. Something like |^tran|sformers||^|revenge |of fallen|^ to |^transformers|^revenge of fallen|^... Cold anybody please help to build the regular expression using sed . many thanks. Please use code tags next time for... (1 Reply)
Discussion started by: kokjek
1 Replies

2. Shell Programming and Scripting

I am learning regular expression in sed,Please help me understand the use curly bracket in sed,

I am learning SED and just following the shell scripting book, i have trouble understanding the grep and sed statement, Question : 1 __________ /opt/oracle/work/antony>cat teledir.txt jai sharma 25853670 chanchal singhvi 9831545629 anil aggarwal 9830263298 shyam saksena 23217847 lalit... (7 Replies)
Discussion started by: Antony Ankrose
7 Replies

3. UNIX for Dummies Questions & Answers

sed expression-help cutting name

Hi, I have some sample names. The regions in red are what I want to extract. AIB13-positive AIB13-blank AIB13-1116-0022999 GNX13-1521-0003532 Each of the sample names are represented as variable ${SAMPLE} within a loop. I've tried extracting the middle region with the following code... (2 Replies)
Discussion started by: jdilts
2 Replies

4. Shell Programming and Scripting

sed returns error "sed: -e expression #1, char 18: unterminated `s' command"

Hello All, I have something like below LDC100/rel/prod/libinactrl.a LAA2000/rel/prod/libinactrl.a I want to remove till first forward slash that is outputshould be as below rel/prod/libinactrl.a rel/prod/libinactrl.a How can I do that ??? (8 Replies)
Discussion started by: anand.shah
8 Replies

5. UNIX for Advanced & Expert Users

sed: -e expression #1, char 0: no previous regular expression

Hello All, I'm trying to extract the lines between two consecutive elements of an array from a file. My array looks like: problem_arr=(PRS111 PRS213 PRS234) j=0 while } ] do k=`expr $j + 1` sed -n "/${problem_arr}/,/${problem_arr}/p" problemid.txt ---some operation goes... (11 Replies)
Discussion started by: InduInduIndu
11 Replies

6. Shell Programming and Scripting

Help with sed regular expression

Hi all, I want to get a substring from a string based on given delimiter, for example: str="foo|bar|baz" with delimiter "|", I want to get one substring at each time with the order number the substring in the whole string, given 1 to get "foo", given 2 to get "bar", given 3 to get "baz", I... (2 Replies)
Discussion started by: Roy987
2 Replies

7. Shell Programming and Scripting

Please explain this SED expression

can anyone please explain this code? sed ':t /<VirtualHost/,/VirtualHost>/ { /VirtualHost>/!{ $!{ N; bt } }; /name/d; }' infile (4 Replies)
Discussion started by: jacky29
4 Replies

8. Shell Programming and Scripting

Regular expression (sed)

Hi I need to get text that are within "" For example File: asdasd "test test2" sadasds asdda asdasd "demo demo2" Output: test test2 demo demo2 Any help is good Thank you (12 Replies)
Discussion started by: blito_loco
12 Replies

9. Shell Programming and Scripting

Regular expression with sed

Hi, I'm trying following:echo "test line XA24433 test" | sed 's/.*X\(.*\)/X\1/' XA24433 test While I want the output as: XA24433 I want to grab the words starting with letter X till the next space, this word can be anywhere in the line. (9 Replies)
Discussion started by: nervous
9 Replies
Login or Register to Ask a Question