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
# 1  
Old 04-03-2009
NAWK - seach pattern for special characters - } dbl qt - sng qt

i'm puzzled....

trying to look for the pattern }"'. but the below code returns to me the message below (pattern is curley queue + dbl qt + sng qt + period)

Quote:
awk: 0602-592 String }"'. cannot contain a newline character. The source line is 1.

Code:
  
nawk -v pat="\}\"\'\."'
          {
            if (match($0, pat)) {
               before = substr($0,1,RSTART-1);
                 do {
                     pattern = substr($0,RSTART,RLENGTH);
                     printf("%s%s\n", before, pattern);
                     $0=substr($0, RSTART+RLENGTH)
                    } while (match($0, pat))
                 }
          }' $HOME/TEMP/X1.dat >> $HOME/TEMP/X2.dat

Quote:
Thank you in advance for your help!
# 2  
Old 04-03-2009
a sample data file, please.
# 3  
Old 04-03-2009
I'm sure its not this easy, but is it a direct cut and paste of your code?

Code:
  
nawk -v pat="\}\"\'\."'

It looks like the last single quote is out of place...

Code:
nawk -v pat="\}\"\'\."

# 4  
Old 04-03-2009
sample data file:

Quote:

mp itable Join_plcy_trm_plcy_sts_prty_Extract__table_ "$SCHEMA_DB"'/db2eee_cr.dbc' -select 'WITH S_PH AS (SELECT PLCY_KY,
Max(s.PLCY_EVNT_KY) as PLCY_EVNT_KY
FROM '"${Gedwschema}"'.plcy_sts s, '"${Gedwschema}"'.vhcl v
output to be 2 results

1rst result for "${Gedwschema}"'.plcy_sts
2nd result for '"${Gedwschema}"'.vhcl
# 5  
Old 04-03-2009
The output is different though...
Code:
nawk -v pat="}\"'\." -f dan1.awk dan1.txt

# 6  
Old 04-03-2009
Quote:
Originally Posted by d.f.
I'm sure its not this easy, but is it a direct cut and paste of your code?

Code:
  
nawk -v pat="\}\"\'\."'

It looks like the last single quote is out of place...

Code:
nawk -v pat="\}\"\'\."


the single quote you removed at the end of the nawk line (i think ??) encapsulates the whole rest of the expression... no?


Code:
 
nawk -v pat="\}\"\'\."'
          {
            if (match($0, pat)) {
               before = substr($0,1,RSTART-1);
                 do {
                     pattern = substr($0,RSTART,RLENGTH);
                     printf("%s%s\n", before, pattern);
                     $0=substr($0, RSTART+RLENGTH)
                    } while (match($0, pat))
                 }
          }' $HOME/TEMP/X1.dat >> $HOME/TEMP/X2.dat

# 7  
Old 04-03-2009
My bad.....

needed a space before the single quote that incapsulates all that comes after the nawk line..... i appologize..


Quote:
Originally Posted by danmauer
i'm puzzled....

trying to look for the pattern }"'. but the below code returns to me the message below (pattern is curley queue + dbl qt + sng qt + period)




Code:
  
nawk -v pat="\}\"\'\." '
          {
            if (match($0, pat)) {
               before = substr($0,1,RSTART-1);
                 do {
                     pattern = substr($0,RSTART,RLENGTH);
                     printf("%s%s\n", before, pattern);
                     $0=substr($0, RSTART+RLENGTH)
                    } while (match($0, pat))
                 }
          }' $HOME/TEMP/X1.dat >> $HOME/TEMP/X2.dat

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