The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Special Forums > Windows & DOS: Issues & Discussions
Google UNIX.COM


Windows & DOS: Issues & Discussions Questions involving Unix to Windows (Desktop or Server) go here. Any Windows/DOS questions should go here as well.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Extracting data from text file based on configuration set in config file suparnbector Shell Programming and Scripting 3 08-09-2007 11:25 PM
Exporting text file data to csv l_jayakumar Shell Programming and Scripting 3 09-18-2005 08:27 PM
filter data deep.singh UNIX for Dummies Questions & Answers 3 08-14-2005 08:24 PM
How to extract data from a text file negixx Shell Programming and Scripting 1 07-19-2005 06:30 PM
getting data out from a text file skotapal Shell Programming and Scripting 7 09-14-2002 08:10 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #15  
Old 04-15-2008
radoulov's Avatar
addict
 

Join Date: Jan 2007
Location: Milano, Italia/Варна, България
Posts: 1,930
Strange,
it seems that you're running this:

Code:
awk 'END { if (f) print x } $0 ~ v && f++ /^--/ { if (f) print x; x = f = 0 }
{ x = x ? x RS $0 : $0 }' v="^IP=172.18.0.1$" file
instead of this:
Code:
awk 'END { if (f) print x } $0 ~ v && f++
/^--/ { if (f) print x; x = f = 0 }
{ x = x ? x RS $0 : $0 }' v="^IP=172.18.0.1$" file
...
Anyway,
try separating the statments explicitly:

Code:
awk 'END { if (f) print x } $0 ~ v && f++;
/^--/ { if (f) print x; x = f = 0 }
{ x = x ? x RS $0 : $0 }' v="^IP=172.18.0.1$" file
Reply With Quote
Forum Sponsor
  #16  
Old 04-16-2008
Registered User
 

Join Date: Apr 2008
Posts: 7
How I run that awk script in Solaris unix shell? (Couple of lines, error comes if I run it on one line).

Last edited by Hone1975; 04-16-2008 at 06:23 AM.
Reply With Quote
  #17  
Old 04-16-2008
radoulov's Avatar
addict
 

Join Date: Jan 2007
Location: Milano, Italia/Варна, България
Posts: 1,930
Quote:
Originally Posted by Hone1975 View Post
How I run that awk script in Solaris unix shell? (Couple of lines, error comes if I run it on one line).
The last version should work well even on one line,
could you post the command and the errors (just copy/paste them from your terminal)?
Reply With Quote
  #18  
Old 04-16-2008
Registered User
 

Join Date: Apr 2008
Posts: 7
awk 'END { if (f) print x } $0 ~ v && f++; /^--/ { if (f) print x; x = f = 0 } { x = x ? x RS $0 : $0 }' v="^IP=172.18.0.1$" list.txt
Illegal variable name.
Reply With Quote
  #19  
Old 04-16-2008
radoulov's Avatar
addict
 

Join Date: Jan 2007
Location: Milano, Italia/Варна, България
Posts: 1,930
Quote:
Originally Posted by Hone1975 View Post
awk 'END { if (f) print x } $0 ~ v && f++; /^--/ { if (f) print x; x = f = 0 } { x = x ? x RS $0 : $0 }' v="^IP=172.18.0.1$" list.txt
Illegal variable name.
I cannot reproduce it, could you try it with nawk?

Try this also:

1. Put this code into a file (for example Hone1975.awk) preserving the format:

Code:
END { if (f) print x }
$0 ~ v && f++
/^--/ { if (f) print x; x = f = 0 }
{ x = x ? x RS $0 : $0 }
2. Run it like this:

Code:
nawk -f Hone1975.awk v="^IP=172.18.0.1$" list.txt
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
solaris

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 09:40 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0