The UNIX and Linux Forums  

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 for text pattern rider29 Shell Programming and Scripting 6 09-01-2009 04:08 PM
Searching a pattern in file and deleting th ewhole line containing the pattern Shazin Shell Programming and Scripting 1 07-24-2009 12:27 PM
sed: Find start of pattern and extract text to end of line, including the pattern TestTomas Shell Programming and Scripting 5 05-27-2009 12:16 PM
search a pattern and if pattern found insert new pattern at the begining pitagi Shell Programming and Scripting 7 02-12-2009 10:27 PM
comment/delete a particular pattern starting from second line of the matching pattern imas Shell Programming and Scripting 4 10-13-2008 03:37 AM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 4 Weeks Ago
TehOne TehOne is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 55
sed to awk (regex pattern) how?

Hello,

I am trying to covert a for statement into a single awk script and I've got everything but one part.

I also need to execute an external script when "not found", how can I do that ?


Code:
for TXT in `find debugme -name "*.txt"` ;do
FPATH=`echo $TXT | sed 's/\(.*\)\/\(.*\)/\1/'`

how to add it to the following awk code?


Code:
find debugme -name "*.txt" | awk 'BEGIN{
    while( (getline line < "debug.files" ) > 0 ) {
        a[++d]=line
    }
    close("debug.files")
}
{
    filename=$0
    #FPATH=?????
    while( (getline line < filename ) > 0 ){
        f=0
        m=split(line,t," ")
        if ( t[1] ~ "(rar|r[0-9]+)" ){
            for(i=1;i<=d;i++){
                if( a[i] ~ t[1] ){
                    print found
                    f=1
                }
            }
            if (f==0){ print not found }
        }
    }
    close(filename)
}'

 

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 02:30 AM.


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