Unix Script for Flat File Rename

Sun microsystems Unix essentials featuri...
January 21, 2010 at 08:53:56
Specs: Windows XP

On a daily basis, I have two .csv flat files in an FTP directory (sun solaris box) that I must manually rename. I need help creating a unix script to truncate the file name and remove the "_mmddyy" portion. Details are as follows:

File directory on FTP server: servername\export\home\userID\data

The two files in that directory that must be renamed:

As I am a unix novice, is there a simple script that can remove the _mmddyy portion from each of the .csv files, giving me the following result?
Data_Withdrawals_mmddyy.csv -> Data_Withdrawals.csv
Data_Trx_mmddyy.csv -> Data_Trx.csv

I'd appreciate any help I can get here, thanks.

See More: Unix Script for Flat File Rename

January 21, 2010 at 21:14:16

# I'll do the hard part - getting the new file name
# Use the Korn shell parameter substitution to trim the date
# Data_Withdrawals_mmddyy.csv -> Data_Withdrawals.csv


# get the extension
echo "ext is: $ext"

# get the basename
echo "$basename"

echo "$trim_the_date"

# put the filename back together
echo "$newfile"

# let me know if you have any questions

Report •
Related Solutions

Ask Question