Always helps to see the actual script and the actual error message.
Two points:
No spaces before/after the equals sign
Folder='/zzz/xxx/yyy'
file='abc def 123.txt'
Which quotes?
Anything between single quotes is protected from the shell and no substitution will take place. You need double quotes to preserve the spaces but definitely not single quotes when there is a variable involved.
I can't take credit for the meat and potatoes of this script, but I can't remember who gave it to me and from what forum. But it does replace : in file names and replaces them with a - and then changes the file extention to dat. This might work for you. I hope this helps. I use this to take files from UNIX and make them readable in DOS, and then clean up after itself.
#!/bin/csh
cd /home/files
# cp $1 /tmp
cp *DH /tmp
cd /tmp
ls -1 *.DH > /tmp/DH.list
set filelist=`cat /tmp/DH.list`
foreach x ($filelist)
set newname=`echo $x|sed 's/:/-/g'`
echo $newname
cp $x /tmp/$newname
end
cd /tmp
ls -1 *.DH > /tmp/DH1.list
set filelist=`cat /tmp/DH1.list`
foreach x ($filelist)
set newname=`echo $x|sed 's/DH/dat/g'`
echo $newname
cp $x /tmp/$newname
end
rm *:*:*.dat
zip dh *.dat
allocate floppy_0
rm -r /floppy/floppy0/*
cp dh.zip /floppy/floppy0
deallocate floppy_0
rm *.DH
rm *.dat
rm dh.zip
rm DH*
---------- Post updated at 07:19 AM ---------- Previous update was at 07:18 AM ----------
sorry not only in bash but also in KSH.
BR
---------- Post updated at 07:22 AM ---------- Previous update was at 07:19 AM ----------
kindly find some details and example below:-
Quoting means just that, bracketing a string in quotes. This has the effect of protecting special characters in
the string from reinterpretation or expansion by the shell or shell script. (A character is "special" if it has an
interpretation other than its literal meaning, such as the wild card character -- *.)
bash$ ls -l [Vv]*
-rw-rw-r-- 1 bozo bozo 324 Apr 2 15:05 VIEWDATA.BAT
-rw-rw-r-- 1 bozo bozo 507 May 4 14:25 vartrace.sh
-rw-rw-r-- 1 bozo bozo 539 Apr 14 17:11 viewdata.sh
bash$ ls -l '[Vv]*'
ls: [Vv]*: No such file or directory