# Whats wrong with the syntax

**URL:** <https://community.unix.com/t/whats-wrong-with-the-syntax/164121>\
**Category:** Shell Programming and Scripting\
**Created:** [August 10, 2006, 4:56pm UTC](https://community.unix.com/t/whats-wrong-with-the-syntax/164121 "2006-08-10T16:56:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dsravan](https://community.unix.com/letter_avatar/dsravan/32/5_5575768a8748004e209b776fc1b2916d.png) [@dsravan](https://community.unix.com/u/dsravan)\
**Post date:** [August 10, 2006, 4:56pm UTC](https://community.unix.com/t/whats-wrong-with-the-syntax/164121/1 "2006-08-10T16:56:17Z")

</div>

Whats wrong with below logic or syntax????

> [@](#):
>
> if [$file=$sourcefilepattern] then  
> mv "$file" $arch  
> elseif [$file=$targetfilepattern] then  
> mv "$file" $targetarchive  
> fi

---

<div class="post-metadata">

**Author:** ![vgersh99](https://community.unix.com/user_avatar/community.unix.com/vgersh99/32/14851_2.png) [@vgersh99](https://community.unix.com/u/vgersh99)\
**Post date:** [August 10, 2006, 5:09pm UTC](https://community.unix.com/t/whats-wrong-with-the-syntax/164121/2 "2006-08-10T17:09:41Z")

</div>

a missing ';' after the ']' ?  
I don't know - what's the error message?

---

<div class="post-metadata">

**Author:** ![dsravan](https://community.unix.com/letter_avatar/dsravan/32/5_5575768a8748004e209b776fc1b2916d.png) [@dsravan](https://community.unix.com/u/dsravan)\
**Post date:** [August 10, 2006, 5:29pm UTC](https://community.unix.com/t/whats-wrong-with-the-syntax/164121/3 "2006-08-10T17:29:10Z")

</div>

Vgresh,

I added the below logic and it seems I am doing wrong by comparing 2 different file formats. Here the sourcefile pattern and targetfile pattern are different:

> [@](#):
>
> for file do  
> if [["$file" = "$sourcefilepattern"]] then  
> mv "$file" $arch  
> fi  
> if [["$file" = "$targetfilepattern"]] then  
> mv "$file" $targetarchive  
> fi

Thanks any way

---

<div class="post-metadata">

**Author:** ![vgersh99](https://community.unix.com/user_avatar/community.unix.com/vgersh99/32/14851_2.png) [@vgersh99](https://community.unix.com/u/vgersh99)\
**Post date:** [August 10, 2006, 5:32pm UTC](https://community.unix.com/t/whats-wrong-with-the-syntax/164121/4 "2006-08-10T17:32:18Z")

</div>

once again, what exactly happens? any error messages?

---

<div class="post-metadata">

**Author:** ![dsravan](https://community.unix.com/letter_avatar/dsravan/32/5_5575768a8748004e209b776fc1b2916d.png) [@dsravan](https://community.unix.com/u/dsravan)\
**Post date:** [August 10, 2006, 5:41pm UTC](https://community.unix.com/t/whats-wrong-with-the-syntax/164121/5 "2006-08-10T17:41:08Z")

</div>

Debug output:

> [@](#):
>
> archive2.ksh AUD61\_TLG DLY  
> + export FILENAME=AUD61\_TLG  
> + export FILETYPE=DLY  
> + arch=/biddf/ab6498/dev/ctl/arch  
> + export arch  
> + export STG\_LOG\_DIR=/edwstage/Logs  
> + export targetarchive=/edwstage/Archive  
> + [DLY = DLY]  
> + export RUNDTFILE=audt\_run\_dt\_dly.txt  
> + cut -f2 -d:  
> + grep OLD\_DT /edwstage/Logs/audt\_run\_dt\_dly.txt  
> + export OLD\_DT=20060601  
> + cut -f2 -d:  
> + grep NEW\_DT /edwstage/Logs/audt\_run\_dt\_dly.txt  
> + export NEW\_DT=20060701  
> + cd /biddf/ab6498/dev/ctl  
> + sourcefilepattern=AUD61\_TLG\_DLY\_???\_20060601.dat  
> + targetfilepattern=AUD61\_TLG\_DLY\_MKT\_20060701.dat.new  
> + [[AUD61\_TLG = AUD61\_TLG\_DLY\_???\_20060601.dat]]  
> + [[AUD61\_TLG = AUD61\_TLG\_DLY\_MKT\_20060701.dat.new]]  
> + [[DLY = AUD61\_TLG\_DLY\_???\_20060601.dat]]  
> + [[DLY = AUD61\_TLG\_DLY\_MKT\_20060701.dat.new]]+ targetfilepattern=AUD61\_TLG\_DLY\_MKT\_20060701.dat.new  
> + mv AUD61\_TLG\_DLY\_MKT\_20060701.dat.new /edwstage/Archive  
> mv: AUD61\_TLG\_DLY\_MKT\_20060701.dat.new: cannot access: No such file or directory  
> + cd /edwstage/Archive  
> + compress /edwstage/Archive
