Remove lasts characters from a string

Hi all,

Consider i have a directory /tmp/test and inside this directory i have the following files:
1.svf.tmp
2.svf.tmp
3.svf.tmp

How can i remove the last four characters of every file in irder for the directory to be as:
1.svf
2.svf
3.svf

I use the following command but id doesn't seem to work
sed 's/\(.*\).../\1/'

Thamk you!

cut -d. -f1,2 infile

ls -1 | awk '{print substr($0,1,length($0)-4)}'

Sorry but nothing of the above seems to work.

have in mind that the files inside /tmp/test directory could be more than 1000. So i need to create a script that will remove the '.tmp' from all the 1000 files

Hi,

for i in *tmp; do mv $i ${i%.tmp}; done

This uses shell's build in string manipulations feature to remove the last four characters .tmp.

HTH Chris

cut has no problems with more than 1000 lines; nor has awk or sed.

root@isau02:/data/tmp/testfeld> cat infile
1.svf.tmp
2.svf.tmp
3.svf.tmp
root@isau02:/data/tmp/testfeld> cut -d. -f1,2 infile
1.svf
2.svf
3.svf

According to the directory listing you can just do

ls -1 /tmp/test | cut -d. -f1,2 infile

Maybe you tell us what kind of error you get if it still doesn't work.

It worked..
Thank you very much all..