Advertisement

07.09.2008 at 03:32PM PDT, ID: 23552135
[x]
Attachment Details

Error message 'binary operator expected' when executing shell script

Asked by keserm in Bourne-Again Shell (bash), Linux Programming, Shell Scripting

Tags: Linux, Li, shell script, binary operator expected, Shell script error message 'binary operator expected'

I have this script that will search through one level folders and if there are files found than gzip, delete fles and than move gzip to archive folder. The problem I have is when it finds more than one file in the same folder I get error message:
line 6: [: /directory/path/folder/filename.txt: binary operator expected  

Thank you.Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
#!/bin/sh
find . -name "*[0-9]" | while read name
do
        arch=`echo $name | sed "s:.*/::"`
        cd $arch
        if [ -f /directory/path/$arch/* ] ; then
                tar -czf $arch.tar.gz *
                /bin/mv $arch.tar.gz ../out/$arch.tar.gz
                /bin/rm -f *
        fi
        cd ..
done
[+][-]07.09.2008 at 03:41PM PDT, ID: 21969033

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.09.2008 at 03:56PM PDT, ID: 21969102

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.09.2008 at 04:14PM PDT, ID: 21969207

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.09.2008 at 04:16PM PDT, ID: 21969216

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.09.2008 at 04:43PM PDT, ID: 21969363

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.09.2008 at 05:01PM PDT, ID: 21969447

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.09.2008 at 05:03PM PDT, ID: 21969456

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.09.2008 at 05:19PM PDT, ID: 21969531

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.09.2008 at 08:41PM PDT, ID: 21970277

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.09.2008 at 11:37PM PDT, ID: 21970903

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Bourne-Again Shell (bash), Linux Programming, Shell Scripting
Tags: Linux, Li, shell script, binary operator expected, Shell script error message 'binary operator expected'
Sign Up Now!
Solution Provided By: wilhelm_voigt
Participating Experts: 2
Solution Grade: A
 
 
[+][-]07.10.2008 at 09:12AM PDT, ID: 21974887

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.10.2008 at 09:23AM PDT, ID: 21975006

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628