aspose file tools*
The moose likes Linux / UNIX and the fly likes Help me George!!!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Help me George!!!!!" Watch "Help me George!!!!!" New topic
Author

Help me George!!!!!

sujatha mamidala
Greenhorn

Joined: Nov 20, 2000
Posts: 19
Hi,
Could you please let me know what's wrong with this script.
#!/bin/sh
for FILENAME in *.jsp
do
echo "processing ${FILENAME}"
name=Zaizar
cnt='grep -c $name ${FILENAME}'
echo $cnt
done
Instead of giving me the count it's simply printing
'grep -c $name ${FILENAME}'
Please let me know what's wrong here.
Bytheway i use C shell.
Thanks A Lot,
Suja.

[This message has been edited by sujatha mamidala (edited March 16, 2001).]
George Brown
Ranch Hand

Joined: Sep 26, 2000
Posts: 919
sujatha,
as an aside, although you might be using the C shell, the script you describe is using the Bourne shell (or Bourne Again shell, or POSIX shell, depending on the setup of the UNIX/Linux/BSD box that you use).
The first line of your script...
#!/bin/sh
... is an indication to the executing shell what program will be used to interpret the lines of this script. So you will type the name of the script in your C shell session, and that will see the first line of your script and invoke the Bourne shell (/bin/sh) to interpret the lines of the script. Likewise, if you wanted to use perl you would use the following line as the first line of your perl script:
#!/usr/local/bin/perl
(assuming that perl resides in /usr/local/bin of course)
By the way, you don't need to address things to me personally, there are many people more experienced than me who check this forum too and can reply to these posts, it's better not to exclude them - you'd be missing out on their good advice if you do that.
sujatha mamidala
Greenhorn

Joined: Nov 20, 2000
Posts: 19
Once again Thanks a lot George.
Zkr Ryz
Ranch Hand

Joined: Jan 04, 2001
Posts: 187
Problably out of date sujatha mamidala but I hope this helps
:
use `` instead of ''
if you use simple quotes you are using a string and `` is for executing commands

#!/bin/sh
for FILENAME in *.jsp
do
echo "processing ${FILENAME}"
name=Zaizar
cnt='grep -c $name ${FILENAME}'
echo $cnt
done

This script will work the same way

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Help me George!!!!!