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
User History and commnad log jaydeep_sadaria UNIX for Dummies Questions & Answers 5 02-11-2008 04:01 AM
How to apply the awk commnad ? preethgideon UNIX for Dummies Questions & Answers 3 10-30-2006 09:32 PM
sorting file and unique commnad.. amon Shell Programming and Scripting 2 02-16-2006 05:19 AM
Commnad for getting bandwidth usage skotapal UNIX for Dummies Questions & Answers 5 01-16-2003 08:47 AM
How does commnad tail implement chenhao_no1 High Level Programming 1 08-23-2002 01:13 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 Rating: Thread Rating: 1 votes, 1.00 average. Display Modes
  #1 (permalink)  
Old 12-14-2004
props props is offline
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
;;
  #2 (permalink)  
Old 12-14-2004
videsh77 videsh77 is offline
Registered User
  
 

Join Date: Aug 2004
Posts: 144
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
props props is offline
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
bhargav bhargav is offline Forum Advisor  
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
videsh77 videsh77 is offline
Registered User
  
 

Join Date: Aug 2004
Posts: 144
props,
Solution I suggested do not involve grep, its an alternative to grep.
  #6 (permalink)  
Old 12-14-2004
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
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
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 10:31 PM.


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