NAWK - seach pattern for special characters - } dbl qt - sng qt


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting NAWK - seach pattern for special characters - } dbl qt - sng qt
# 8  
Old 04-03-2009
Thank you

in summary: (to firm up my understanding)

1) the } doesn't need an escape backslash before it, as it's interpreted literally within the double quotes surounding the pattern.

2) there's no need of an escape backslash before the single quote.... if withing the double quotes surrounding the pattern ---- i'll will take note of that.


Quote:
Originally Posted by vgersh99
The output is different though...
Code:
nawk -v pat="}\"'\." -f dan1.awk dan1.txt

# 9  
Old 04-03-2009
here's a little bit better regex pat - you can remove the 'before' part in the 'printf' to get what you actually want:
Code:
nawk -v pat="'\"[^ ][^ ]*}\"'\.[^ ][^ ]*" -f dan1.awk dan1.txt

# 10  
Old 04-03-2009
just to firm up my understanding...

below pattern means:

Single quote + none or any number of non-spaces before } + } + double quote + single quote + period + none or any number of non-spaces before “ + double quotes


Quote:
Originally Posted by vgersh99
here's a little bit better regex pat - you can remove the 'before' part in the 'printf' to get what you actually want:
Code:
nawk -v pat="'\"[^ ][^ ]*}\"'\.[^ ][^ ]*" -f dan1.awk dan1.txt

# 11  
Old 04-03-2009
Quote:
Originally Posted by danmauer
just to firm up my understanding...

below pattern means:

Single quote + none or any number of non-spaces before } + } + double quote + single quote + period + none or any number of non-spaces before “ + double quotes
correct.
# 12  
Old 04-03-2009
Thanks again for your time and patience.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Replace Pattern with another that has Special Characters

Hello Team, Any help would be much appreciated for the below scenario: I have a sed command below where I am trying to replace the contents of 'old_pkey' variable with 'new_pkey' variable in a Soap request file (delete_request.txt). This works fine for regular string values, but this new_pkey... (8 Replies)
Discussion started by: ChicagoBlues
8 Replies

2. Shell Programming and Scripting

Nawk special numbers

Just stumbled over a terrible feature in nawk derivates. I did not find it documented in man pages. HP-UX 11.31: echo info | awk '{print $1+0}' inf echo nano | awk '{print $1+0}' nan echo info | awk '{print $1-$1}' -nanSolaris 10: echo info | nawk '{print $1+0}' Inf echo nano | nawk... (5 Replies)
Discussion started by: MadeInGermany
5 Replies

3. Shell Programming and Scripting

awk seach and printing a particular pattern

Hi i need a help for this. the output of a command is like below 1 /tmp/x 2.2K /tmp/y 3.2k /tmp/z 1G /tmp/a/b 2.2G /tmp/c 3.4k /tmp/d Now i need to grep for the paths which are in GB..like below 1G /tmp/a/b 2.2G /tmp/c pls suggest me, how can i... (12 Replies)
Discussion started by: kumar85shiv
12 Replies

4. Shell Programming and Scripting

Replace special characters with Escape characters?

i need to replace the any special characters with escape characters like below. test!=123-> test\!\=123 !@#$%^&*()-= to be replaced by \!\@\#\$\%\^\&\*\(\)\-\= (8 Replies)
Discussion started by: laknar
8 Replies

5. Shell Programming and Scripting

Sed or awk : pattern selection based on special characters

Hello All, I am here again scratching my head on pattern selection with special characters. I have a large file having around 200 entries and i have to select a single line based on a pattern. I am able to do that: Code: cat mytest.txt | awk -F: '/myregex/ { print $2}' ... (6 Replies)
Discussion started by: usha rao
6 Replies

6. Shell Programming and Scripting

SED equivalent for grep -w -f with pattern having special characters

I'm looking for SED equivalent for grep -w -f. All I want is to search a list of patterns from a file. Also If the pattern doesn't match I do not want "null returned", rather I would prefer some text as place holder say "BLANK LINE" as I intend to process the output file based on line number. ... (1 Reply)
Discussion started by: novice_man
1 Replies

7. Shell Programming and Scripting

awk search pattern with special characters passed from CL

I'm very new to awk and sed and I've been struggling with this for a while. I'm trying to search a file for a string with special characters and this string is a command line argument to a simple script. ./myscript "searchpattern" file #!/bin/sh awk "/$1/" $2 > dupelistfilter.txt sed... (6 Replies)
Discussion started by: cue
6 Replies

8. Shell Programming and Scripting

sed delete pattern with special characters

Hi all, I have the following lines <b>A gtwrhwrthwr text hghthwrhtwrtw </b><font color='#06C'>; text text (text) <b>B gtwrhwrthwr text hghthwrhtwrtw </b><font color='#06C'>; text text (text) <b>J gtwrhwrthwr text hghthwrhtwrtw </b><font color='#06C'>; text text (text) and I would like to... (5 Replies)
Discussion started by: stinkefisch
5 Replies

9. Shell Programming and Scripting

how to seach junk or special char in vi edit

Hi, I have text file which is genrated by some external system(not sure of what is the edirot used) I copied to my Solaris machine and did vi found some strange text like below in one line. Ren\351 Erich I wanted to find all places that contain \351, in vi I am unable search unsing... (2 Replies)
Discussion started by: McLan
2 Replies

10. Shell Programming and Scripting

nawk-how count the number of occurances of a pattern, when don't know the pattern

I've written a script to count the total size of SAN storage LUNs, and also display the LUN sizes. From server to server, the LUNs sizes differ. What I want to do is count the occurances as they occur and change. These are the LUN sizes: 49.95 49.95 49.95 49.95 49.95 49.95 49.95 49.95... (2 Replies)
Discussion started by: cyber111
2 Replies
Login or Register to Ask a Question