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
User History and commnad log jaydeep_sadaria UNIX for Dummies Questions & Answers 5 02-11-2008 12:01 AM
How to apply the awk commnad ? preethgideon UNIX for Dummies Questions & Answers 3 10-30-2006 05:32 PM
sorting file and unique commnad.. amon Shell Programming and Scripting 2 02-16-2006 01:19 AM
Commnad for getting bandwidth usage skotapal UNIX for Dummies Questions & Answers 5 01-16-2003 04:47 AM
How does commnad tail implement chenhao_no1 High Level Programming 1 08-22-2002 10:13 PM

Closed Thread
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-14-2004
Registered User
 

Join Date: Oct 2003
Location: uk
Posts: 15
grep commnad

echo "Enter a,: \c"
read answer
echo
case "$answer" in
a|A)
echo "Enter a file :\c"
read $answer
echo " Enter a string to be searched :\c"
read $answer2
if [ ! -s $answer ]
then
echo " file doesn't exist"
else grep $answer2 $answer # is there an alternative way # to declare this ?
fi
;;
Forum Sponsor
  #2 (permalink)  
Old 12-14-2004
Registered User
 

Join Date: Aug 2004
Posts: 141
I am not much sure with your problem statement. But I assume , you want to search a string within some file.

Alternate way I know is using awk,

awk "/$searchstring/" $file2bSearched
  #3 (permalink)  
Old 12-14-2004
Registered User
 

Join Date: Oct 2003
Location: uk
Posts: 15
what you've said is what i want to do

but using grep
  #4 (permalink)  
Old 12-14-2004
bhargav's Avatar
Registered User
 

Join Date: Sep 2004
Location: USA
Posts: 511
Quote:
else grep $answer2 $answer # is there an alternative way # to declare this ?

Sry ! Have n't understood yr question properly.


What i would do passing of file and string from commnad from command line and do grep like this

grep $2 $1


also ...what o/p do u want from grep, in yr question ?
  #5 (permalink)  
Old 12-14-2004
Registered User
 

Join Date: Aug 2004
Posts: 141
props,
Solution I suggested do not involve grep, its an alternative to grep.
  #6 (permalink)  
Old 12-14-2004
zazzybob's Avatar
Registered Geek
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
Quote:
Originally posted by props
what you've said is what i want to do

but using grep
Why the static requirement that this must be solved using grep? One could well assume that this could be some kind of homework question. Maybe you should try reading the manual page for grep.

Also; your Original Post isn't really a question at all. "Is there an alternative way to declare this". Why do you want to declare it differently? What exactly are you trying to do? What is the purpose of your script? Or is this just what the assignment tells you to do?!

Please review the rules . Looking back through your previous posts it seems you consistently post homework questions on this site, and appear to cause arguments when the point is made. Therefore, I am making the decision to lock this thread before such an argument ensues.

Thanks
ZB
Google The UNIX and Linux Forums
Closed Thread

Thread Tools
Display Modes




All times are GMT -7. The time now is 09:54 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