Hello,
#this script renames schematic file for model year change
#my = model year prefix
my="lsd"
for i in 'ls lsb*'
do
old=$i
new='echo $i | cut - c4 - c30'
mv $i $my$new
end
i: Undefined variable
What am I missing or doing wrong?
Hello,
#this script renames schematic file for model year change
#my = model year prefix
my="lsd"
for i in 'ls lsb*'
do
old=$i
new='echo $i | cut - c4 - c30'
mv $i $my$new
end
i: Undefined variable
What am I missing or doing wrong?
The shell cannot expand the * symbol inside ' ', also lose the ls....
#change
for i in 'ls lsb*'
# to
for i in lsb*
I think the last bit should be 'done', not 'end'.
And "for file in `ls *`" is a useless use of backticks, you can just do "for file in *" and it'll do the same thing without ls.
Also, for starters:
my="lsd"
for i in 'ls lsb*'
Is this right??
Hi.
The error looks C-Shell-like.
If I run this in C-Shell I get lots more errors:
my=lsd: Command not found.
for: Command not found.
do: Command not found.
i: Undefined variable.
The syntax - although not correct - looks more bourne shell. What shell is it supposed to be run in?
Try this
#this script renames schematic file for model year change
#my = model year prefix
my="lsd"
for i in `ls lsb*`
do
old=$i
new=`echo $i | cut -c4 -c30`
done
mv $i $my$new
end
The full format of the CAD file is cs(ModelYearIdentifier)yyy-70030-123456. So, engineers use a baseline design and make modifications. I have to be my own admin in this regard. Cp and mkdir all go well.
I want to replace the ModelYearIdentifier in the filename. I'm told SED and Perl are over kill for the task at hand. The ModelYearIdentifier is always the 3 character following the 3 types of CAD files.
So, with the posts below, I will try the following;
for i in lsb*
code block
done
---------- Post updated at 03:47 PM ---------- Previous update was at 03:20 PM ----------
% is my prompt = C shell on SunOS 5.8.
finger -m user name
/bin/csh
I still get the i : Undefined Variable.