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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
String compare in shell script kiranlalka Shell Programming and Scripting 2 11-29-2008 09:39 AM
compare two tables using shell script dtidke Shell Programming and Scripting 1 06-25-2008 06:34 AM
perl script to list filenames that do not contain given string royalibrahim Shell Programming and Scripting 21 04-22-2008 02:55 PM
How to compare the dates in shell script vaji Shell Programming and Scripting 9 02-28-2007 12:34 AM
shell script cant recognize if else compare jaseloh Shell Programming and Scripting 6 12-06-2005 11:34 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 06-11-2009
rajinavaneethan rajinavaneethan is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 8
Angry String compare with list in shell script

Hi ,

I am new to shell scripting.

below is my requirement :
1) while running my .sh i will pass a string
2) i have to extract a folder name under a /config folder
3) i need to compare a input string in the folder name list
4) if that is true i have to continue my job else i have to give the message to the user

here is my code :


Code:
if [ $# -ne 1 ]; then
echo "Invalid arguments!"
echo ""
echo "job Name: $(basename $0) "
echo " Please pass the environment variable "
return 1
else
env_name="$1"
fi
 
LIST="`ls -ltr conf/ | grep -v "total" | grep -v "pre_swh" | awk '{ print $NF "," }'`";
if ["$env_name" in "$LIST"]
then
echo "correct"
else
echo "incorrect"
fi
counter1=`expr $counter1 + 1`
#done

while running this am gettin the error
sample2.sh[25]: [test: not found.

Please anyone help me on this

Last edited by vidyadhar85; 06-11-2009 at 10:47 PM.. Reason: code tag added
 

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 08:38 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