Register
It is currently Sun Dec 21, 2014 6:58 pm

script...


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Sun Jul 12, 2009 6:16 pm   

Joined: Sun Jul 12, 2009 5:56 pm
Posts: 2
Hello,
I am rather new to this and I need some guidance...I need to write a script that will use a loop to generate a list of files ( 2 types one ending in .csv and the other ending in .dat) that can be deleted one at a time in the loop

Thank you in advance...


Top
 Profile  
 PostPosted: Mon Jul 13, 2009 12:47 am   

Joined: Mon Nov 17, 2008 7:25 am
Posts: 221
I think you need to be a little more specific in what you want to do.

Generating a list from what?
Is there some path to where the files are?
Should the file list be stored in a .csv and a .dat? And if so, in which format should this be saved? (csv is obvious, just comma-seperated. But the .dat file?)

Just write down the scenario of what you want to do and be a little more precise in your description of it :)

I'll write some quickie-code to show you how this might be done.
Code:
#!/bin/bash
csv_out="file.csv"
dat_out="file.dat"
for i in /tmp/*; do
   echo "$i," >> $csv_out
   echo "$i," >> $dat_out
   rm $i
done


This will delete all files in the folder /tmp and also write 2 files, file.csv and file.dat containing the files seperated by a comma

Best regards
Fredrik Eriksson


Top
 Profile  
 PostPosted: Mon Jul 13, 2009 4:13 pm   

Joined: Sun Jul 12, 2009 5:56 pm
Posts: 2
Thank you for your reply. I will try what you suggest and then post my results here later.

Thanks again


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP