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
grep in Shell script Krishnaramjis Shell Programming and Scripting 1 02-19-2008 05:43 PM
grep script drchris UNIX for Dummies Questions & Answers 4 05-17-2007 06:32 AM
a script to simplify the use of grep kemobyte Shell Programming and Scripting 2 05-01-2007 10:57 AM
grep from a script... hamsasal UNIX for Advanced & Expert Users 1 08-14-2005 01:24 AM
script ksh/awk/grep hoang Shell Programming and Scripting 2 06-01-2002 12:20 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-30-2008
Registered User
 

Join Date: Apr 2008
Posts: 8
Smile Grep within a script

Hi,

I am new to this - I have a unix command (below) that I would like to make automated. I would like the script to run the below command line but would like user input for '\[11 \]' and '\[075871-A-28APR08\]' as these values will change depending on what i'm searching for. Is this possible? if so please help.

grep '\[11 \]' REUTERS_200804*.log | grep '\[075871-A-28APR08\]'

Thanks Darren
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 04-30-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 2,688
Code:
#!/bin/sh
grep "$1" REUTERS_200804*.log | grep "$2"
Usability and error handling left as an exercise.
Reply With Quote
  #3 (permalink)  
Old 04-30-2008
Registered User
 

Join Date: Apr 2008
Posts: 8
Thanks I will give it a go
Reply With Quote
  #4 (permalink)  
Old 04-30-2008
Registered User
 

Join Date: Apr 2008
Posts: 8
I am stuck and not sure how to begin
Reply With Quote
  #5 (permalink)  
Old 04-30-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 2,688
Copy/paste that into a text file, say "gep", chmod +x gep, start debugging. You'd use it like gep pattern1 pattern2
Reply With Quote
  #6 (permalink)  
Old 04-30-2008
Registered User
 

Join Date: Apr 2008
Posts: 8
Ok thanks will do
Reply With Quote
  #7 (permalink)  
Old 04-30-2008
Registered User
 

Join Date: Apr 2008
Posts: 11
hope this works for you

please add this in a script and change the permissions to chmod 755 for that file to make it executable.



#!/bin/sh

echo "enter the first value : \c";
read first_value

echo "enter the second value : \c";
read second_value

grep "\[$fist_value \]" REUTERS_200804*.log | grep "\[$second_value\]";

exit 0;
Reply With Quote
Google UNIX.COM
Reply

Tags
solaris

Thread Tools
Display Modes




All times are GMT -7. The time now is 04:40 AM.


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

Content Relevant URLs by vBSEO 3.2.0