Unix Shell - need help on some test operations in if loo

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > November 2006 > need help on some test operations in if loo





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author need help on some test operations in if loo
atishay

2006-11-29, 1:30 am

I have a shell script in which i assign values to following 3 vars.

lastModifiedMonth=`\echo ${sccsDate}|cut -d '/' -f 2`
lastModifiedDate=`\echo ${sccsDate}|cut -d '/' -f 3`
lastModifiedYear=`\echo ${sccsDate}|cut -d '/' -f 1

if i have a test condition like following
if [ "x${lastModifiedMonth}" != "x" -a "x${lastModifiedDate} !=
"x" -a "x${lastModifiedYear}" != "x" ] ; then

i get following error in the script.

listChanges.sh: syntax error at line 29: `end of file' unexpected

i change it to
if [ "x${lastModifiedMonth}" != "x" ] ; then

now it works.


What am in doing wrong?

cheers..atishay

Bill Seivert

2006-11-30, 1:33 am

atishay wrote:
> I have a shell script in which i assign values to following 3 vars.
>
> lastModifiedMonth=`\echo ${sccsDate}|cut -d '/' -f 2`
> lastModifiedDate=`\echo ${sccsDate}|cut -d '/' -f 3`
> lastModifiedYear=`\echo ${sccsDate}|cut -d '/' -f 1
>
> if i have a test condition like following
> if [ "x${lastModifiedMonth}" != "x" -a "x${lastModifiedDate} !=

Missing a double quote following "x${lastModifiedDate}

> "x" -a "x${lastModifiedYear}" != "x" ] ; then
>
> i get following error in the script.
>
> listChanges.sh: syntax error at line 29: `end of file' unexpected
>
> i change it to
> if [ "x${lastModifiedMonth}" != "x" ] ; then
>
> now it works.
>
>
> What am in doing wrong?
>
> cheers..atishay
>


Bill Seivert
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com