add a date suffix (or prefix) to your files when copying or archivingBy adding the date to your file, whether as a prefix or suffix, will aid in sorting files. As a prefix it'll sort more cleanly but will be less readable as the file names will be longer, if using a browser it might not display.
you could create a short "wrapper" script, e.g. "vicp.sh" :vi vicp.sh #!/bin/bash # vicp.sh - created 2015-09-01 jm - wrapper script to copy files before and after edit /usr/bin/cp $1 $1.before-`date +'%Y%m%d-%H%M'` ################################################################################## # if desired, add an archive Directory path to copied file name, e.g. # uncomment the following 2 lines and comment out the line above this comment # mkdir BAK # /usr/bin/cp $1 BAK/$1.before-`date +'%Y%m%d-%H%M'` ################################################################################## /usr/bin/vi $1 /usr/bin/cp $1 $1.after-`date +'%Y%m%d-%H%M'` ################################################################################## # if desired, add an archive Directory path to copied file name, e.g. # uncomment the following 2 lines and comment out the line above this comment # /usr/bin/cp $1 BAK/$1.after-`date +'%Y%m%d-%H%M'` ################################################################################## /usr/bin/ls -l $1* /usr/bin/ls -l BAK/$1* make it executable and put it in your "bin" directory: ------------------------------------------------ --> chmod 744 vicp.sh ------------------------------------------------ --> which vicp.sh /home/luser/bin/vicp.sh ------------------------------------------------ (you could also drop the .sh, so you'd only have to type: vicp filename )NOTES: ------------------------------------------------ date suffix easiest to sort and readdate +'%Y_%m_%d-%b' ------------------------------------------------ --> date +'%Y_%m_%d-%b' 2015_09_01-Sep ------------------------------------------------ --> echo "`date +'%Y_%m_%d-%b'`" 2015_09_01-Sep the system will sort from left to right numerically, then alphabetically... sorting first by year, then month (numeric value) and day works well, also by hour (H) and minute (M) ------------------------------------------------read about the quotes from hellNOTE: THE QUOTES and other SPECIAL CHARACTERS ARE VERY, VERY IMPORTANT! the first is the DOUBLE QUOTE (or Quotes): " - where there is ONE, there will be another ending that string! the second is a "tick" or "grave" or "accent" - where there is ONE, there will be another ending that string! - it is found under the ~ (tilde) under theusing a single quote in place of double quote results in displaying the command stringTHE quotes in this STRING are WRONG: if you use a single quote (') the command line treats it as a quote instead of a command, while the double quote (") would allow the tick/grave/accent (`) to tell the shell to execute the command within the quoted line. ------------------------------------------------ USE SINGLE QUOTES TO DISPLAY COMMAND STRING --> echo '`date +'%Y_%m_%d_%b'`' `date +%Y_%m_%d_%b`------------------------------------------------ --> date +'%Y_%m_d%d' 2015_09_d01 ------------------------------------------------ --> date +'%Y_m%m_%d' 2015_m09_01 ------------------------------------------------ --> date +'ymd-%Y_%m_%d' ymd-2015_09_01 ------------------------------------------------ --> date +'%Y_%m_%d-%M' Y = 2015 (year), m = 09 (month in #), d = 01 (date in #), M = 39 (minutes) 2015_09_01-39 ------------------------------------------------ --> date +'%Y_%m_%d-%B' 2015_09_01-September ------------------------------------------------ --> date +'%Y_%m_%d-%b' 2015_09_01-Sep ------------------------------------------------ |
|
CAMERAS: Nikon Lumix Canon DSLRs Lenses Computers: Toshiba Toughbook Apple Dell BOOKS: Auto Repair Diesels BioDiesel PARTS: Wagoneer J-truck Benz VW
books and computers
|
|
|