The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Issue with String Comparison (if) waterdrop Shell Programming and Scripting 3 12-04-2008 06:20 PM
string comparison Jatsui Shell Programming and Scripting 5 02-04-2008 04:28 PM
string comparison fedora Shell Programming and Scripting 2 01-03-2007 03:20 PM
Help with if loop (string comparison) psynaps3 Shell Programming and Scripting 4 07-07-2006 02:36 AM
String Comparison abey High Level Programming 1 10-19-2005 12:08 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 03-23-2009
Swapna173 Swapna173 is offline
Registered User
  
 

Join Date: May 2008
Posts: 23
string comparison

Hi Guys

i need to write a script to check the file structure

I have added the the file headers in the configuration file and execute the file at the start of the script.

Now the function

Code:
checkFileStructure()
{
	echo "Inside the function"
	filetocheck=$1
	fileheader=$2
	if [[ "$filetocheck" == "Asset_Class" && "$fileheader" != "$HEADER_ASSET" ]] 
	then
		echo "For Asset"
		export Status=22
		return $Status

	elif [[ "$filetocheck" == "Currency" && "$fileheader" != "$HEADER_CURRENCY" ]]
	then
		echo "For Currency"
		export Status=22
		return $Status

	elif [[ "$filetocheck" == "Expense" && "$fileheader" != "$HEADER_EXPENSE" ]]
	then
		echo "For Expense"
		export Status=22
		return $Status

	elif ][ "$filetocheck" == "Geography" && "$fileheader" != "$HEADER_GEOGRAPHY" ]]
	then
		echo "For Geo"
		export Status=22
		return $Status
		
	elif [ "$filetocheck" == "Instrument" && "$fileheader" != "$HEADER_INSTRUMENT" ]]
	then
		echo "For Inst"
		export Status=22
		return $Status
	else
               	export Status=0
		return $Status
        fi
}
checks the filename and the headers and returns 22 in case does not match and 0 in case it matches.

all the file headers are tab separated string with some spel characters

the && operatos is not working. everytime it goes into the if & elif statements not into the else statement

How to solve the problem.

Last edited by Yogesh Sawant; 03-25-2009 at 02:42 AM.. Reason: added code tags
 

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 03:45 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