I'm new in unix scripting, what i'm trying to to is set up
a script to to the following:
change file names such as {file 1} into {file_1},
{my file 1} into {my_file_1}
my script setup as:
in_file = 'ls -1'
for file in $in_file
do
if test -f "file"
then
n_check1='echo $file | sed 's/ */_/g'`
n_check2='echo $n_check1 | tr '[A-Z]''[a-z] |
sed 's/^_//g'`
n=1
while test -f "$n_check2"
do
nfile_name = $n_check2.$n
n='expr $n +1'
if test -f "$nfile_name"
then
nw_name = $nfile_name
fi
done
cp $file $nw_file
else
echo $file "is not a reqular file."1>&2
fi
done
when i run it from the command line as extra.sh
i get the message as extra.sh : not a directory.
please help thanks.
a script to to the following:
change file names such as {file 1} into {file_1},
{my file 1} into {my_file_1}
my script setup as:
in_file = 'ls -1'
for file in $in_file
do
if test -f "file"
then
n_check1='echo $file | sed 's/ */_/g'`
n_check2='echo $n_check1 | tr '[A-Z]''[a-z] |
sed 's/^_//g'`
n=1
while test -f "$n_check2"
do
nfile_name = $n_check2.$n
n='expr $n +1'
if test -f "$nfile_name"
then
nw_name = $nfile_name
fi
done
cp $file $nw_file
else
echo $file "is not a reqular file."1>&2
fi
done
when i run it from the command line as extra.sh
i get the message as extra.sh : not a directory.
please help thanks.