What does "!{$!..." means in sed ?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting What does "!{$!..." means in sed ?
# 1  
Old 03-08-2017
What does "!{$!..." means in sed ?

Hi everyone

i have this command but i have some difficulty to understand it
Code:
 sed -n '/{/!b;:a;/}/!{$!{N;ba;}};{/}/p}' test.trc

the first part it's ok it but for the second pattern with "}" and the ending i have difficulty to understand it.

Can someone explain it to me in detail for each part ?

thanks a lot
# 2  
Old 03-08-2017
Quote:
Originally Posted by ade05fr@yahoo.f
i have this command but i have some difficulty to understand it
Generally: commands in one-liner style do not enhance the readability all too much. If you don't understand it it is a good idea to first write it out, like i have done:


Code:
sed -n '/{/ ! b          # Line rule ("!"=NOTted): if line (not) contains "{", branch
        :a               # target for branching
        /}/ ! {          # line rule (NOTted again): if line (not) contains "}" do
              $ ! {      # line rule (NOTted again): if line is (not) the last line, do
                    N    # append next line to pattern space
                    ba   # branch to target a (see above, line 2)
                  }
              }
        {                # i don't understand this bracket
            /}/p         # line rule: if line contains "}" print it
        }' test.trc

I hope this helps.

bakunin
These 3 Users Gave Thanks to bakunin For This Post:
# 3  
Old 03-08-2017
Thanks it helps a lot to the comprehension of this command.
This User Gave Thanks to ade05fr@yahoo.f For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

What does "force devmap reload" as in "multipath -r" means for my system and stability of my system?

Cannot present unpresented disks back again. On a test server tried this as a solution "multipath -r" and it worked. Too worried to try it in production before I know all the information. Any info would be appreciated! Also some links to the documentation on this specific issue could help a... (1 Reply)
Discussion started by: jsteppe
1 Replies

2. Solaris

Means to check if some process is running on "n" number of machines

Team, I would like to know, if we have any command in Solaris to verify, if some process is listening on a port on a set of machines. for eg: Wrote the below script, and found that when a process is listening on that port, then it just waits there and doesnt come out. Rather, I would like... (6 Replies)
Discussion started by: msgforsunil
6 Replies

3. Shell Programming and Scripting

how to use "cut" or "awk" or "sed" to remove a string

logs: "/home/abc/public_html/index.php" "/home/abc/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" how to use "cut" or "awk" or "sed" to get the following result: abc abc xyz xyz xyz (8 Replies)
Discussion started by: timmywong
8 Replies

4. Shell Programming and Scripting

Using sed to find text between a "string " and character ","

Hello everyone Sorry I have to add another sed question. I am searching a log file and need only the first 2 occurances of text which comes after (note the space) "string " and before a ",". I have tried sed -n 's/.*string \(*\),.*/\1/p' filewith some, but limited success. This gives out all... (10 Replies)
Discussion started by: haggismn
10 Replies

5. UNIX for Advanced & Expert Users

What does "__FD_PRN_" means in perl code ?

I have seen something like this in a perl code: $_ =~ s/__FD_PRN_/\\(/g What does this "__FD_PRN_" means. I have searched google but was not able to find any info regarding this. Appreciate if some one can refer to a link for these characters. From comments/code it used to substitue "(" with... (3 Replies)
Discussion started by: sarbjit
3 Replies

6. What is on Your Mind?

What does "Eris Free" means, from the acronym EFNET

Ok so I have searched google pretty exstensively to find this out, no luck so far . . . Basically I wanted to know what "Eris Free" means, from the acronym EFNET. I was thinking that Eris is generally to do with discordianism, but have so far only found it as a reference to... (2 Replies)
Discussion started by: U_C_Dispatj
2 Replies

7. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

8. Shell Programming and Scripting

What "-a" operator means in "if" statement

Hi I am trying to figure out what the following line does, I work in ksh88: ] && LIST="$big $LIST" Not sure what "-a" means in that case. Thanks a lot for any advice -A (1 Reply)
Discussion started by: aoussenko
1 Replies

9. Shell Programming and Scripting

cat $como_file | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g'

hi All, cat file_name | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g' Can this be done by using sed or awk alone (4 Replies)
Discussion started by: harshakusam
4 Replies

10. UNIX for Advanced & Expert Users

Any idea what this counter means "tcpTimRetrans"

I am chasing an issue where I see drop packets, in order to dig the problem further I issue netstat -s -P tcp command which shows me the stats from the tcp perspective. In that stats I see a counter which is "tcpTimRetrans" which increments along with "tcpRetransSegs". When both of these counter... (3 Replies)
Discussion started by: purechgo
3 Replies
Login or Register to Ask a Question