Help with how to account for changing filenames


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with how to account for changing filenames
# 1  
Old 12-26-2008
Help with how to account for changing filenames

The files below are essentially “lookup files” used in a series of scripts that run through the look up files and grab the correct Group Name and File Type and then unless I have the file name specified will replace the variable with the corresponding group name when processing the files before FTPing them to remote servers.

I have a replace string that will replace ZZZZ with the Group Name. Up to this point I have always known what my input will be so that I can specify my output.

File_1 GROUP NAME:
JUNK
BUNK
GTO1
...
File_2 FILE TYPE:
JUNK TEST
JUNK EMAIL
BUNK TEST
BUNK PART
GTO1 PART
GTO1 EMAIL
...
File_3 Destination File NAME: (ZZZZ is a place holder and will be replaced in the actual file name with Group name after processing.)

JUNK EMAIL EMAIL.ZZZZ.date.txt
JUNK TEST JUNK_TEST.date.txt
BUNK TEST TEST.ZZZZ.date.txt
GTO1 PART GTO1.ZZZZ.date.txt
GTO1 TEST GTO1TEST1.date.txt
...

Here is my replace funtion which works just fine for ZZZZ

sub_qs()
{
typeset string=$1;
typeset replace_string=$2;
string=`echo $string|awk -v replace_string=$replace_string '{gsub(/\Z\Z\Z\Z/,replace_string); print $0;}'`
echo $string
}

So now that the background is over, I now have an issue that I am not sure how to handle.
I need to add new file type for certain group names for which I cannot account for the complete filename because it will different every time it is sent to me.
I was thinking that my lookup files should have entries below added to them to account for it, What I do not know how to do is to bring the YYY stright from the file name but I do know that I will only have to account for 3 characters.

File_2 FILE TYPE:
GTO1 EMAIL_2
File_3 FILE NAME:
GTO1 EMAIL_2 GTO1.ZZZZYYY.date.txt
or I would be fine with
GTO1 EMAIL_2 GTO1.GTO1YYY.date.txt (and not using my current replace string)

Thanks for any and all assistance.
# 2  
Old 12-26-2008
I forgot to mention, that all of the outputs will be in a groupname specific folder if that makes any difference. My current setup allows for this.
ie
/user/home/BUNK/
TEST_date.txt
/user/home/GTO1/
PART_date.txt
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. Forum Support Area for Unregistered Users & Account Problems

Problem changing the email address associated with my UNIX.com account

Hello I have had an account for many years. I have attempted to change the email address associated with my account. After logging-in to unix.com and revising my email address, I received a 're-verification' email at that new address. The first link in that email took me to a page with the... (1 Reply)
Discussion started by: irb
1 Replies

2. How to Post in the The UNIX and Linux Forums

Simultaneously try to execute commands after connecting to remote account to one account

I have made password less connection to my remote account. and i tried to execute commands at a time. but i am unable to execute the commands. ssh $ACCOUNT_DETAILS@$HOST_DETAILS cd ~/JEE/*/logs/ (1 Reply)
Discussion started by: kishored005
1 Replies

3. UNIX and Linux Applications

Firefox changing hidden filenames

Is firefox changing the filename of this hidden file for anyone else? I tried in firefox 3, 4, and 6. They all got changed when I tried when I downloaded the file. Firefox removed the leading dot that makes the file be hidden. MEGAUPLOAD - The leading online storage and file delivery service (2 Replies)
Discussion started by: cokedude
2 Replies

4. Shell Programming and Scripting

Passing password when changing the user account

Hi All, I have one requirment.. I need to change my id to some sudo account in a server.. Actually our username/passwd will be stored in one gip file like below... $cat .a.gz #It's hidden file username passwd $ So I tried the below script to pass the password when i sudo to... (7 Replies)
Discussion started by: raghu.iv85
7 Replies

5. Shell Programming and Scripting

changing filenames in a directory to a number within a loop

hey guys. i'm new to shell scripting but not new to programming. i want to write a script that will take all the files in the current directory that end with a particular filetype and change all their names to a number in order. so, it would take all the jpg files and sort them in alphabetical... (30 Replies)
Discussion started by: visitorQ
30 Replies
Login or Register to Ask a Question