![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| File Archive Script | KeesH | Shell Programming and Scripting | 10 | 06-09-2008 08:11 AM |
| Script to archive file | indira | UNIX for Dummies Questions & Answers | 0 | 05-22-2007 07:15 AM |
| How to transfer files (By using generic script) when using sftp | gsri | Shell Programming and Scripting | 0 | 08-28-2006 06:39 PM |
| script to archive all the log files | tintedwindow | Shell Programming and Scripting | 0 | 06-13-2006 07:51 PM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Generic Shell Script to Archive a file
Would appreciate if any one can paste a generic schell script to archive a file with date stamp by passing the file with fullpath as parameter
For Eg. /apps/scripts/Archive_File.sh /data_home/project_home/file.txt this should place the file in the following directory /data_home/project_home/Archive Any help is really appreciated...I'm kinda new to KSH and please help me. Thanks |
| Forum Sponsor | ||
|
|
|
|||
|
Not a big ksh person, but how about:
Code:
mv $1 `echo $1 | sed 's/\/[^/][^/]*//'`/Archive/`echo $1 | sed 's/.*\///'`.`date +"%Y-%m-%d"` |
|
|||
|
awesome...Thanks a lot for your help...a little bit of refinement...
For some directories it is ARCHIVE, for some archive and for some it is Archive.....How do I include this condition to check for the available archive directory |
|
|||
|
Actually I could not get it to work
here is the error that I get + sed s/\/[^/][^/]*// + echo test_file.txt + sed s/.*\/// + echo test_file.txt + date +%Y-%m-%d + mv test_file.txt test_file.txt/ARCHIVE/test_file.txt.2008-07-23 mv: cannot rename test_file.txt to test_file.txt/ARCHIVE/test_file.txt.2008-07-23: Not a directory File Location /data_home/scripts/test_file.txt Archive Location /data_home/scripts/ARCHIVE Thanks for your help |
|
|||
|
It works perfectly...Thanks a lot for your help....
Would like to know if there is a way to see if the check if the directories ARCHIVE/archive/Archive exists and based on that move the files to the Archive directory...since I want to write a generic script that archives the files to archive directory...but for some projects the archive directory is ARCHIVE, for some it is Archive and for others it is Archive. Once agian thanks for all the help |