|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | 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 and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi all, Thanks for previous help. How to include this in script, I need to tar files which are present in /var/spool/cron/crontabs directory (used for crontab) excluding those files which are having extension .au Code:
/var/spool/cron/crontabs>>ls -ltr | grep -v .au total 438 -rw------- 1 root root 16 Oct 19 2008 batch010 -rw------- 1 root root 58 Oct 19 2008 batch451 -rw------- 1 root root 752 Oct 19 2008 lp -rw------- 1 root root 287 Oct 19 2008 sys -rw-r--r-- 1 root root 1 Feb 11 2009 root -rw------- 1 root qad 2217 Apr 2 2010 batch471 -rw------- 1 root qad 462 Apr 18 2010 ibi Please advice, I guess this might work: - Code:
find /var/spool/cron/crontabs -grep -v .au -exec tar cvf {} \;But I need to put this in the script:- Last edited by Scrutinizer; 02-04-2013 at 05:37 AM.. Reason: code tags |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Code:
find /var/spool/cron/crontabs -not -name "*.au" -exec tar cvf myArchive.tar {} \; |
| The Following User Says Thank You to balajesuri For This Useful Post: | ||
manalisharmabe (02-04-2013) | ||
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Had you a recent bash, you could use extended globbing: Code:
$ shopt -s extglob $ tar cf myArch.tar /var/spool/cron/crontabs/!(*.au) |
| The Following User Says Thank You to RudiC For This Useful Post: | ||
manalisharmabe (02-04-2013) | ||
|
#4
|
|||
|
|||
|
Quote:
Code:
tar cvf myarchive.tar 1st.file and the second file found will trigger execution of Code:
tar cvf myarchive.tar 2nd.file and so on. Because of the "c"-option in tar every time a new file is found it will create "myarchive.tar" anew, overwriting the previous one. To go with this method one would have to create the tar archive previously and then add to it: Code:
tar cvf myArchive.tar
find /var/spool/cron/crontabs -not -name "*.au" -exec tar Af myArchive.tar {} \;But it would probably be easier to feed "tar" the list of file names via <stdin>: Code:
find /var/spool/cron/crontabs -not -name "*.au" -print | tar -cf myArchive.tar I hope this helps. bakunin |
| The Following User Says Thank You to bakunin For This Useful Post: | ||
manalisharmabe (02-04-2013) | ||
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
Thanks Guys for reply,
I will soon post what I did to get this done. |
| Sponsored Links | |
|
|
#6
|
||||
|
||||
|
As your on redhat you probably have GNU tar so you could use the --exclude option: Code:
tar cvf myArchive.tar --exclude='*.au' /var/spool/cron/crontabs |
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
Quote:
Regards, Alister |
| The Following User Says Thank You to alister For This Useful Post: | ||
vbe (02-06-2013) | ||
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| List files older that 7 days in a dir, excluding all subdirs | jwbijl | UNIX for Dummies Questions & Answers | 6 | 06-04-2012 09:38 AM |
| Excluding file from tar | chriss_58 | Shell Programming and Scripting | 3 | 11-17-2010 07:28 AM |
| Excluding a file from tar... | lwif | UNIX for Advanced & Expert Users | 2 | 05-11-2010 09:23 AM |
| help writing rm script excluding specific titled dir | nomados | Shell Programming and Scripting | 1 | 01-15-2010 07:30 PM |
| Excluding files using tar cXzf | sampipe | UNIX for Dummies Questions & Answers | 11 | 07-28-2005 09:46 AM |
|
|