| | |
Seeks help to compare strings stored in arrays
![]() |
•
•
Join Date: Aug 2007
Posts: 80
Reputation:
Solved Threads: 10
Hi
I'm trying to compare two files names using the function given below.
The files to be compared are named as
xxx_yyy_abc_def_.rtf && xxx_yyy_abc_def_.html
The extentions and the underscores are removed from the file names and then stored in two different arrays. So the file names stored in arrays are like:
HTML_FILE_ARR[0]=abc def
FILE_ARR[0]=abc def
Their word counts are same.
But when I compare the two strings stored in different arrays, they are never equal.
Can you please help me out with it?
I'm trying to compare two files names using the function given below.
The files to be compared are named as
xxx_yyy_abc_def_.rtf && xxx_yyy_abc_def_.html
The extentions and the underscores are removed from the file names and then stored in two different arrays. So the file names stored in arrays are like:
HTML_FILE_ARR[0]=abc def
FILE_ARR[0]=abc def
Their word counts are same.
But when I compare the two strings stored in different arrays, they are never equal.
Can you please help me out with it?
Shell Scripting Syntax (Toggle Plain Text)
ARR_INC=0 function storeFilesInArray { cd ../sharepoint_url set -a HTML_FILE_ARR for HTML_FILE in `ls $STREAM*.html` do HTML_FILE_NAME=`echo $HTML_FILE` truncateHtmlFileName HTML_FILE_ARR[$ARR_INC]="${HTML_FILE_NAME}" ARR_INC=`expr $ARR_INC + 1` done FILE_ARR_LEN=`expr $ARR_INC - 1` ARR_INC=0 cd ../result set -a FILE_ARR for FILE in `ls $STREAM*_.rtf` do FILE_NAME=`echo $FILE` truncateFileNames FILE_ARR[$ARR_INC]="${FILE_NAME}" ARR_INC=`expr $ARR_INC + 1` done for NAME in "${FILE_ARR[@]}" do for HTML_NAME in "${HTML_FILE_ARR[@]}" do echo $NAME "..." $HTML_NAME echo "$NAME" | wc -c echo "$HTML_NAME" | wc -c if [ "${NAME}" == "{$HTML_NAME}" ]; then echo ${NAME} "....." ${HTML_NAME} fi done done }
•
•
Join Date: Aug 2007
Posts: 80
Reputation:
Solved Threads: 10
This is ugly but it works!
Shell Scripting Syntax (Toggle Plain Text)
if [ "$NAME*" == "$HTML_NAME*" ]; then
![]() |
Other Threads in the Shell Scripting Forum
- Previous Thread: Replacing characters in a foldername
- Next Thread: cronjob problem in the script
| Thread Tools | Search this Thread |





