Posted: Sat 10 Mar 2012, 20:05 Post subject:
Bash - #!/bin/sh - #!/bin/bash
I want to make backups of favorite directories and did wrote a little GUI application that does it. Now i want to make the program not to overwrite existing backups - so i want to add date and time to the file names.
How do i grep, sed or whatever needed date and time out, into a format (variable etc) that i can add easily onto a path-/file name?
this will only remove the file iff the copy is succesful and will not overwrite existing files with the same date stamp and name
btw for current time use
Code:
NEWFILE="`date +%F@%T`-$FILE"
_________________ Puppy Web Desktop Now with pet packages - Pet Packaging 100 & 101 Last edited by technosaurus on Sun 11 Mar 2012, 03:27; edited 2 times in total
current date and time or the date the file was created?
Current date and time is needed, but maybe others wish to get date and time of file? If you know the solution for both - hm - who knows, maybe someone else will be grateful for that?
the problem with using current date and time is that you may end up backing up files that are already backed up... so you end up with 1000s of copies of the same picture of a funny cat with different date stamps. _________________ Puppy Web Desktop Now with pet packages - Pet Packaging 100 & 101
This --> `date +%F` <-- is exactly what i needed. I just do create directories with that name and then save the files inside the directory. _________________ Useful Software for Puppy! LazY Puppy - a Paradise Puppy! - DE & EN ISO 2.0.2-0.0.5 available
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 vote in polls in this forum You cannot attach files in this forum You can download files in this forum