Thanks and congrats to all for their great efforts building this site simply superb for all unix administrators.
My requirement is to remove extensions of the files in the current directory. I'm doing it using below script which is working but i think it is very inefficient as i use lot of variables.I want to get done by avoiding usage of tempfile file and any other temp files being used.
#!/usr/bin/bash
ls -l |awk '{print $9}' >/list
cat /list |while read line
do
echo $line >/tempfile
first=`cut -f1 -d'.' /tempfile`
echo $first >>/output.txt
mv $line $first
done
Thanks Lorcan for your quick reply. The command just displays the files without extension but how to add "mv" most efficiently as i need to rename the files?
for file in *
do
if [ -f $file ] ; then
# name without extension
name=${file%\.error*}
mv ${file} ${name}
echo ${name} "complete" >> output.txt
fi ;
done