If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below. ** If you are logged in, most ads will not be displayed. **

Newbie scripting - file extensions..

Hi There Guru's!

I am writing a simple script to move application program files between a live and test environment. Each file can have either a .i extension, or a .p and a .r (source and x-coded). The x-coded file goes to a directory which starts with the same two letters, thus:

/apps/live/src
/apps/live/us/ap
/apps/live/us/br
etc

Source Name = apvomt.p
Compile Name = apvotmp.r

I have managed to create the script which moves the files, provided they are a .p extension, but I now need to check if the extension is a .i

How do I just pick up the last 2 characters of the filename - can I use CUT, or is there another way?

Provided you're using bash and not some other shell, there's a syntax for cutting in variables (maybe other shells can do it as well, but I haven't tried, so I don't know how compatible it is). It looks like this: