LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 03-12-2005, 08:05 AM   #1
max_rsr
LQ Newbie
 
Registered: Mar 2005
Posts: 20

Rep: Reputation: 0
shell script provides an error that a binary operator is required


Please help me with the following Shell script

the scripts seems to ask for a binary operator ..

# mgrep -- search for a file for 3 words in a line
# usage -- mgrep FILENAME word1 word2 word3.

file=$1

if test grep $2 $file
then
if test grep $2 $file | grep $3
then
if test grep $2 $file | grep $3 | grep $4
then
grep $2 $file | grep $3 | grep $4
else
echo $4 not found.
fi
else
echo $3 not found.
fi
else
echo $2 not found.
fi

~
 
Old 03-12-2005, 08:26 AM   #2
Oliv'
Senior Member
 
Registered: Jan 2004
Location: Montpellier (France)
Distribution: Gentoo
Posts: 1,014

Rep: Reputation: 36
Hello,

try this in your if statement:

if test -n "grep $2 $file"
Note: an equivalent syntax:
if [ -n "grep $2 $file" ]

Oliv'
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script help required syntax error sridhar11 Programming 1 10-31-2005 08:38 AM
small shell script required demigor Programming 6 08-08-2005 04:38 PM
Help With A Shell Script Error PhantomFX Linux - Newbie 3 02-17-2005 04:42 AM
Convert from shell script to binary? Anon123 Linux - General 4 06-26-2004 05:53 AM
Shell '>' operator implementation Lord CyKill Programming 1 10-14-2003 04:07 PM


All times are GMT -5. The time now is 08:28 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration