LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-07-2010, 06:33 AM   #1
morad_dba
LQ Newbie
 
Registered: Jun 2010
Posts: 18

Rep: Reputation: 0
variable comparison problem in script


Dear all,

In my script ( run_scr.sh )I wrote the following to count the filenumber of the current directory and if total file is 6 then run show.sh file that contain 'HelloWorld'.

#!/bin/bash
morad=$(ls |wc -l)
if [${morad} -eq 6];
then
./show.sh
fi

when I run the script, it says that
[oracle@rmancat scr_test]$ ./run_scr.sh
./run_scr.sh: line 2: [6=6]: command not found

Please help me..

Regards,
Morad.
 
Old 06-07-2010, 06:37 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
You need spaces after the [ and before the ] in if [${morad} -eq 6]

BTW, the { and } in ${morad} are not wrong but are not necessary.
 
Old 06-07-2010, 08:43 AM   #3
morad_dba
LQ Newbie
 
Registered: Jun 2010
Posts: 18

Original Poster
Rep: Reputation: 0
thanks...

Thanks CATKIN,

It is working !!!!!

Thanks again....
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Problem With Shell Script Variable Usage Crowey Linux - General 2 02-09-2010 01:03 AM
Script to copy specific directory based on variable to folder with that variable name fluxburn Programming 7 01-07-2010 07:59 PM
Problem with bash script - variable name within variable name steven.c.banks Linux - Newbie 3 03-10-2009 03:08 AM
Mysql variable comparison Murdock1979 Programming 2 08-06-2008 04:52 PM
Bash Script Variable Problem jimmy512 Programming 5 05-11-2007 07:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:00 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration