defined value not showing....in the result


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting defined value not showing....in the result
# 1  
Old 01-25-2007
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  
Old 01-26-2007
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to compare the current result with previous line result.?

Hi Gurus, I have requirement to compare current result with previous reuslt. The sample case is below. 1 job1 1 1 job2 2 1 job3 3 2 job_a1 1 2 job_a2 2 2 job_a3 3 3 job_b1 1 3 job_b2 2 for above sample file, GID is group ID, for input line, the job run... (1 Reply)
Discussion started by: ken6503
1 Replies

2. Shell Programming and Scripting

Perl : code on ping showing difference result

Hi all, I am using the below code to ping a code and print whehter the connection is successful or not. use Net::Ping; $p = Net::Ping->new(); my $host = "x.x.x.x"; # print "$host is alive.\n" if $p->ping($host); if ($p->ping($host,3)) { print... (0 Replies)
Discussion started by: scriptscript
0 Replies

3. AIX

Harddisk1 => Defined

I have an IBM 9110-51A p Series Server with AIX 5.3. It has 2 scsi hard disks hdisk0 and hdisk1 (and 4 on disk array). hdisk1 for few days ago is "Defined". When hdisk1 began "defined" i have a new one unknown disk "available" which called hdisk6. The left led of the case of hdisk1 on the... (4 Replies)
Discussion started by: stetsip
4 Replies

4. AIX

Tape drive defined

Hello everyone I have a problem with one of my drives in an aix box. The library is a 3583 and Aix is 5.3 TL9 The problem was that the fibre channel not work and I change the fibre but when I logging to the aix box I got this in the rmt3 lsdev | grep rmt rmt0 Available 03-08-00-6,0... (4 Replies)
Discussion started by: lo-lp-kl
4 Replies

5. Shell Programming and Scripting

Ramdisk already defined

I am trying to mount the ramdisk for sorting, and i get the message "ramdisk already defined." What exactly is /dev/ramdisk0 and is it safe to remove it? # command sudo -S mktd 60 <<EOF initiate EOF # block of code for mktd ... && { print "ramdisk already defined." ... (1 Reply)
Discussion started by: ChicagoBlues
1 Replies

6. UNIX for Dummies Questions & Answers

display the result of wc -l with words before and after the result

hello showrev -p | wc -l returns: 381 What to do in case I want to have this output: number of lines returned by showrev -p is: 381 thx (3 Replies)
Discussion started by: melanie_pfefer
3 Replies

7. Shell Programming and Scripting

Outputting formatted Result log file from old 30000 lines result log<help required>

Well I have a 3000 lines result log file that contains all the machine data when it does the testing... It has 3 different section that i am intrsted in 1) starting with "20071126 11:11:11 Machine Header 1" 1000 lines... "End machine header 1" 2) starting with "20071126 12:12:12 Machine... (5 Replies)
Discussion started by: vikas.iet
5 Replies

8. Linux

environment variable is not defined

moved to correct thread (0 Replies)
Discussion started by: alien12
0 Replies

9. UNIX for Dummies Questions & Answers

User defined service

I want to add a new IP service which executes a script on SCO OS5. I have amended /etc/services and added to port number (3333) I have amended /etc/inetd.conf and added a line for this service but I can't get it to execute my own shell script When I telnet to the IP address on port 3333 I... (1 Reply)
Discussion started by: markdrury
1 Replies

10. AIX

User defined signal 1

Hi, I am just running a incremental back-up on one of my server. But these days It abrubtly fails with below error. ========== User defined signal 1 =========== When I rerun the back-up, It completed successfully.Earlier this was not happening. Any Idea, what could be the problem... (0 Replies)
Discussion started by: nitesh_raj
0 Replies
Login or Register to Ask a Question