Need a simple shell script please overwritting files.
Basically has to operate as follows:
Got the following files: file1 file2 file3 file4 file5 themainfile I want to copy file1 over themainfile, 2 mins later I want to copy file2 over themainfile and continue on from there. It's probably simple but not sure where to even start. Not that fuzzed about using maybe a perl script, doesn't have to be bash script. Thanks, |
Right off the top of my head:
Code:
#!/bin/bash |
That seems to work, cool thanks!
|
Following up on this though, how do I loop it back to the beginning?
End if possible even randomize the file that is being used to overwrite the main file? |
try this one
Code:
while :; do |
K thanks, my filenames are slightly different to this so I want to make sure that I understand the variables.
file$ the $ is then replaced by a number between 1 and 5 ? Can I have the random part be more generic. In my case I have: file1_blablabla file2_totallydifferentdiscription file3_somethingelseagain So it's not just a 1 and 5. If this can't be done then I can always rename the files to have 1 and 5 in there, just somewhat annoying as the filename doesn't clearly indicate what it is. |
try again
Code:
FILE=(file1_blablabla file2_totallydifferentdiscription file3_somethingelseagain) |
Getting the following error:
./rotate.sh: line 4: bad substitution: no `)' in $(( RANDOM |
sorry my mistake. please recheck the script above.
|
Cheers mate, all working fine!
|
All times are GMT -5. The time now is 02:28 AM. |