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
display the result of wc -l with words before and after the result melanie_pfefer UNIX for Dummies Questions & Answers 3 04-30-2008 08:33 AM
Outputting formatted Result log file from old 30000 lines result log<help required> vikas.iet Shell Programming and Scripting 5 12-02-2007 10:43 PM
User defined service markdrury UNIX for Dummies Questions & Answers 1 02-09-2006 01:08 AM
pre defined variables sumsin High Level Programming 7 11-30-2005 12:13 PM
User defined signal 1 nitesh_raj AIX 0 01-29-2005 02:20 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 01-25-2007
happyv happyv is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 209
defined value not showing....in the result

Hi,

PLMN=APPLE
awk ' /is missing/ { flag=1;print > "fruit_output_m1.txt" }
END {
if( flag != 1 )
print "No $PLMN in the store." > "fruit_output_n1.txt"
} ' fruit_result.txt

The output is:

No $PLMN in the store.

Should be:

No APPLE in the store.


Please help!!
  #2 (permalink)  
Old 01-26-2007
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,429
The variable is not substitued by the shell because the texte is between simple quotes.

A possible solution :

Code:
PLMN=APPLE
awk -v  "
    /is missing/ { 
        flag=1;print > \"fruit_output_m1.txt\" 
    }
    END {
        if( flag != 1 )
            print \"No $PLMN in the store.\" > \"fruit_output_n1.txt\"
    } 
     " fruit_result.txt

Another way:

Code:
PLMN=APPLE
awk -v PLMN="$PLMN" '
    /is missing/ { 
        flag=1;print > "fruit_output_m1.txt" 
    }
    END {
        if( flag != 1 )
        print "No", PLMN, "in the store." > "fruit_output_n1.txt"
    } 
     ' fruit_result.txt


Jean-Pierre.
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 02:29 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