Link to home
Start Free TrialLog in
Avatar of awakenings
awakenings

asked on

SUSE 10.0 xargs and opening different file extensions

I am using SUSE 10.0.  I have some files that appear either as .zip or .txt randomly.  Each file has a date / time stamp connected to them.  They are in the following format.

BOBapp04-04-2006@19-00-05.txt.zip
or
BOBapp04-04-2006@19-00-05.txt

    The "BOBapp04-04-2006@19-00-" are standard.  I can add in a date function to that portion of the file.  The 05 is the second and that seems to be random within 20 seconds depending on when the script actually runs.  I would like to determine if it is a txt or zip, extract if it is a zip, then change the file name to something that is not random (but keep the date functionality).

Does anyone have any recommendations?  I'm giving alot of points for this as I want to test the script to get it working before giving out the points!

Awakenings
Avatar of Tim_Utschig
Tim_Utschig

Can you elaborate on "something that is not random" ?

Everything you mentioned so far is a one-liner.
Avatar of awakenings

ASKER

I would love the file name to be;

BOBapp04-04-2006@19-00.txt for example.
SOLUTION
Avatar of Tim_Utschig
Tim_Utschig

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Tim,

      I am testing things here.  You will have to forgive the fact I am a little slow.  I am a windows guy attempting to learn Linux.  I did some testing with some of this.  I could type in unzip BOBapp04-04-2006* and it would unzip the file.  I could type in mv BOBapp04-04-2006@15-00-??.txt app04-04-06.txt and the file would rename.  What I do not get is how do I collect random files and if they are zip, unzip and rename themthem and if they are txt file just rename them.  I was told the xargs command could do that.  Do you have another suggestions?

     I must admit I did not fully understand the statements above as I am no programmer.  How do I take this stuff and make it into a cron job?  I have the date functionality down so that will be easy.  I know how to do a cron job, but I am fuzzy on taking the random endings (txt or zip) and turn them into just functional txt file.  I then intend to run another cron job to run the files through swatch.  I am trying to automate a process to make things easier for me.

Thanks,

awakenings
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial