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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
pstat_getdisk() call doesn’t work properly in HPUX 11.31 (11i V3) sandiworld HP-UX 2 10-25-2007 07:39 AM
my case statement doesn't work.. sureshy UNIX for Dummies Questions & Answers 7 10-25-2002 11:25 AM
unmount doesn't work DISTURBED UNIX for Dummies Questions & Answers 2 07-04-2002 03:14 PM
Repquota doesn't work as Cronjob?!? b416 UNIX for Dummies Questions & Answers 1 04-14-2002 05:44 PM
why doesn't this work????? token High Level Programming 1 09-20-2001 07:08 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-23-2002
Registered User
 

Join Date: May 2002
Posts: 6
grep doesn't work within shell script?

I am trying to run the following code from a script file but it complains that syntax of (both instances of) grep is wrong.

When I copy and paste it to the terminal, it is OK. Any idea what the problem might be?


set i = `grep -c #define flags.h`

while ($i>20)
@ i--
my func (`cat flags.h | grep #define |sed -n '$i{p;q;}' `)
end


Thanks,
Baris
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-24-2002
Registered User
 

Join Date: Apr 2002
Location: Chesterfield, UK
Posts: 124
Hello,

Are you running your shell script under a different shell? ie csh as your command line shell and sh or ksh within your shell script?

Cheers
Helen
Reply With Quote
  #3 (permalink)  
Old 05-24-2002
Registered User
 

Join Date: May 2002
Posts: 6
Helen,

Thanks for the reply. No I am using csh as my command line shell and for the script...

Baris
Reply With Quote
  #4 (permalink)  
Old 05-24-2002
thehoghunter
Guest
 

Posts: n/a
Change your grep statement -

old: grep -c #define flags.h

to any of these -

grep -c '#define' flags.h
grep -c \#define flags.h
grep -c "#define" flags.h
Reply With Quote
  #5 (permalink)  
Old 05-24-2002
Registered User
 

Join Date: May 2002
Posts: 6
Yes, that is the solution. Thanks a lot.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 06:06 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0