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
Regex pppswing Shell Programming and Scripting 5 06-30-2008 11:22 PM
A simple find and replace without using any regex (bash) srikanths Shell Programming and Scripting 2 03-18-2008 08:08 AM
Regex deepakpv Shell Programming and Scripting 6 03-28-2007 05:18 AM
Regex?? Please help lunac UNIX for Dummies Questions & Answers 7 01-30-2007 01:13 PM
sed regex Shakey21 UNIX for Dummies Questions & Answers 4 01-31-2002 09:16 PM

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 08-31-2008
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,538
Code:
awk '/use/ { ++u}/take/{ ++u }
END {
 if ( u == 0 && t == 0 ) {
   print "file: "FILENAME " has no use or take"
 }
}' file*
  #2 (permalink)  
Old 08-31-2008
drl's Avatar
drl drl is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2007
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 711
Hi.
Quote:
Originally Posted by ghostdog74 View Post
Code:
awk '/use/ { ++u}/take/{ ++u }
END {
 if ( u == 0 && t == 0 ) {
   print "file: "FILENAME " has no use or take"
 }
}' file*
Probably intended:
Code:
awk '/use/ { ++u}/take/{ ++t }
cheers, drl
  #3 (permalink)  
Old 08-31-2008
drl's Avatar
drl drl is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2007
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 711
Hi.
Quote:
Originally Posted by ghostdog74 View Post
Code:
awk '/use/ { ++u}/take/{ ++u }
END {
 if ( u == 0 && t == 0 ) {
   print "file: "FILENAME " has no use or take"
 }
}' file*
The awk I use, GNU Awk 3.1.4, does not reset variable when the filename changes, hence the variables remain as set with the most recent increase ... cheers, drl
  #4 (permalink)  
Old 08-31-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Quote:
Originally Posted by Lakris View Post
I guess I misinterpreted the OP, now here is my supersilly superuseless use of cat and pipe...
Code:
for x in *.txt;do cat $x|tr "\n" " "|egrep '(use.*take|take.*use)'&>/dev/null; [ $? == 1 ] && echo $x;done
but I think it gets the job done?

If you take out the useless(tm) stuff, it's a fairly good solution.

Code:
for x in *.txt; do
  tr "\n" " " <"$x" | egrep -v 'use.*take|take.*use' >/dev/null && echo "$x"
done
I believe I've seen egreps which couldn't handle really long lines, so this might not be entirely robust, but the idea is workable.
  #5 (permalink)  
Old 08-31-2008
Lakris Lakris is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 246
"I'll kill that cat..."
Closed Thread

Bookmarks

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 06:59 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