Set the last 4 letter in the filename as a variable

Hi all,

I want to set the last 4 letter in the filename as a variable.
For example, i have AB1234.txt file and i need to have last 4 letter as a variable.

It should be like ;

get last four letter
set var = 1234

How can i write this in C shell??

Thanks,
zibi

Clarify what you are asking with some example. In any case, you should drop csh to something more suitable for scripting like ksh or bash.

Hi Jlliagre, i try to clarify more things but my case like the following;

There is a file named
ABC1234.txt

Script should get the last 4 letter in filename, that would be (1234).
This value will be my variable for further process.

I dont know the CSH codes for these process, that's why i could not write any code.

Thanks,
zibi

Can sed usage be?

set a="alasisas2323423dsdwe112313ll';lthelast1234.txtasa1218jkhjkh12121"
[root@sistem1lnx ~]# echo $a | sed 's/.*\(....\)\.[a-zA-Z]*[0-9]*.*/\1/'
1234