I am using Korn Shell scripting for the following:
I am searching through a directory and getting all the filenames. if the file names have four characters before the extension, then I need to add an X to this to make five.
eg
FILE.txt would need to be FILEX.txt
but
FILES.txt would be fine.
So far
FILES=`ls *.txt 2>/dev/null`
for FILENAME in ${FILES}
do
SHORTNAME=`echo ${FILENAME} | cut -d"." -f1`
But I don't know how to get the length of SHORTNAME variable. Do I need to use awk? Can I use this with Korn Shell.
Please advise, thanks.
I am searching through a directory and getting all the filenames. if the file names have four characters before the extension, then I need to add an X to this to make five.
eg
FILE.txt would need to be FILEX.txt
but
FILES.txt would be fine.
So far
FILES=`ls *.txt 2>/dev/null`
for FILENAME in ${FILES}
do
SHORTNAME=`echo ${FILENAME} | cut -d"." -f1`
But I don't know how to get the length of SHORTNAME variable. Do I need to use awk? Can I use this with Korn Shell.
Please advise, thanks.