The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Search, replace string in file1 with string from (lookup table) file2? gstuart Shell Programming and Scripting 9 06-08-2009 07:11 AM
Extracting a string from one file and searching the same string in other files mohancrr Shell Programming and Scripting 1 09-19-2007 04:17 AM
Replace string B depending on occurence of string A hemangjani Shell Programming and Scripting 1 12-05-2006 05:10 PM
appending string to text file based on search string malaymaru Shell Programming and Scripting 1 06-09-2006 09:53 AM
sed problem - replacement string should be same length as matching string. amangeles Shell Programming and Scripting 4 01-11-2006 06:11 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-18-2008
myguess21 myguess21 is offline
Registered User
  
 

Join Date: Dec 2005
Posts: 15
awk - do not contain string

Hi, I have file which contain following..

1>
(1 rows
(3 rows
(6 rows

I do not want to print these linse.

I came up with this but getting an error.

awk '(NR >13) && ($1!="1>") && if (! ($0 ~ /rows/)) {print $1}' frile1

Ho do I write command so i can skip this lines?

Thanks.
  #2 (permalink)  
Old 02-18-2008
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,123
You can't put an if statement in a pattern and you don't use slashes with the ~ operator. Try the !~ operator...
$0 !~ "rows"
  #3 (permalink)  
Old 02-18-2008
myguess21 myguess21 is offline
Registered User
  
 

Join Date: Dec 2005
Posts: 15
I am still getting an error:

awk '(NR >13) && ($1!='1') && ($0!~"rows") {print $1}' file.out
awk: syntax error near line 1
awk: bailing out near line 1



Quote:
Originally Posted by Perderabo View Post
You can't put an if statement in a pattern and you don't use slashes with the ~ operator. Try the !~ operator...
$0 !~ "rows"
  #4 (permalink)  
Old 02-18-2008
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,123
I don't get an error when I try it. You must be using Solaris. If so, switch to nawk. And please mention your OS when you post a question.
  #5 (permalink)  
Old 02-18-2008
myguess21 myguess21 is offline
Registered User
  
 

Join Date: Dec 2005
Posts: 15
Yes I am using Solaris.

i was able to execute the command but still prints the lines that have "rows" in it.



Quote:
Originally Posted by Perderabo View Post
I don't get an error when I try it. You must be using Solaris. If so, switch to nawk. And please mention your OS when you post a question.
  #6 (permalink)  
Old 02-18-2008
myguess21 myguess21 is offline
Registered User
  
 

Join Date: Dec 2005
Posts: 15
got it. column 2 was printing ROW not ROWS. I change ROWS to ROW and it works.

Thanks for your help.
  #7 (permalink)  
Old 02-18-2008
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,123
I can't reproduce that. It doesn't print lines with "rows" in it for me. But I can't test on Solaris right now. Maybe a Solaris user will check in.
Closed Thread

Bookmarks

Tags
solaris

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:54 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0