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
pstat_getdisk() call doesn’t work properly in HPUX 11.31 (11i V3) sandiworld HP-UX 2 10-25-2007 10:39 AM
my case statement doesn't work.. sureshy UNIX for Dummies Questions & Answers 7 10-25-2002 02:25 PM
unmount doesn't work DISTURBED UNIX for Dummies Questions & Answers 2 07-04-2002 06:14 PM
Repquota doesn't work as Cronjob?!? b416 UNIX for Dummies Questions & Answers 1 04-14-2002 08:44 PM
why doesn't this work????? token High Level Programming 1 09-20-2001 10:08 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-23-2002
barisgultekin barisgultekin is offline
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
  #2 (permalink)  
Old 05-24-2002
Bab00shka Bab00shka is offline
Registered User
  
 

Join Date: Apr 2002
Location: Chesterfield, UK
Posts: 123
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
  #3 (permalink)  
Old 05-24-2002
barisgultekin barisgultekin is offline
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
  #4 (permalink)  
Old 05-24-2002
thehoghunter
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
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
  #5 (permalink)  
Old 05-24-2002
barisgultekin barisgultekin is offline
Registered User
  
 

Join Date: May 2002
Posts: 6
Yes, that is the solution. Thanks a lot.
Sponsored Links
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 09:54 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