Sponsored Content
Top Forums Shell Programming and Scripting Archive directory script with tar/compress Post 302433641 by dazdseg on Wednesday 30th of June 2010 07:04:34 AM
Old 06-30-2010
Code:
for file in `ls ./${SOURCE_DIRECTORY}`

sorry i missed the last tilde sign at the end of the line. this error will go away. when u use that.

can you explain me ... why do u need date parameter for. are u gona check the files with date.
in ur directory are files being made with different dates.. and u want to tar them according to date. let me know if my understanding is correct or can you please explain what u exactly trying to do. because i am not sure why u want date parameter. ??
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

tar command with compress option...

Hi ! i have to write a script that archivs homes not used since 3 years. First, my script gathers the users that are concerned, using the following command : ll -lt /home/*/.sh_history | egrep '2000|1999|1998|1997' | awk '{print $3}' i obtain a list like this : user_1 user_2 ...... (3 Replies)
Discussion started by: tomapam
3 Replies

2. UNIX for Advanced & Expert Users

tar and compress

I need to compress and tar a couple files in a directory, but I also want the original files unchanged, ie if I compress a1.cpp , then a1.cpp becomes a1.cpp.z, but what I want after running the compress utility is to have both a1.cpp as it is and a1.cpp.z and then tar a1.cpp.z to an... (4 Replies)
Discussion started by: muru
4 Replies

3. Shell Programming and Scripting

Search, Tar and Compress in one line

Hi all, I am supposed to collect a huge amount of log files from a unix system (HP-UX) onto a local system. The log files are not in one place, but they are scattered all over the Unix server. The unix server has only limited space, so that I can not create a tar file first and then compress it.... (4 Replies)
Discussion started by: bluesky099
4 Replies

4. UNIX for Dummies Questions & Answers

create tar archive without preserving directory structure?

I am adding some individual files to a tar archive and would like them to be added to the archive without any directory hierarchy, even though the files themselves exist in levels of hierarchy. Unfortunately, tar seems to always preserve the directory hierarchy when it adds the files. Here is... (2 Replies)
Discussion started by: Special_K
2 Replies

5. Shell Programming and Scripting

compress directories with .tar extension

hi guys.. Since am a bit new to shell scripting, can anyone help me with this problem please.. i've been struggling with it since 2 days. :( I have a directory lets say myFolder and within it I have sub directories let say myFolder1.tar, myFolder2, myFolder3, etc. I need to write a shell... (12 Replies)
Discussion started by: kanexxx
12 Replies

6. UNIX for Dummies Questions & Answers

Compress the file using Tar command

Hi, When i am tar the file particular ,csv file format in a folder i am receiving the error Command: tar cf New_data.tar /new/file/mari/getdata/small/*.xml Arguements too long But sometimes i am able to compress other folder but the tar folder contains all the file format and... (10 Replies)
Discussion started by: marivinay
10 Replies

7. Shell Programming and Scripting

tar and compress in one step

I know there is a way to tar up directory and sub-directories and have it compressed all in one command but but the syntax escapes me. I seem to re-call something like this: tar -cvf /tmp/file.tar - | compress ? Can somebody please provide me with the syntax on how to tar/compress and... (6 Replies)
Discussion started by: BeefStu
6 Replies

8. Shell Programming and Scripting

script to compress files in directory that changes its name every day

Hi all I have the following script that should compress a file in a directory: # compress log files older than 2 days find /u01/easydone/DBDUMPS/*.dmp -mtime +2 -exec gzip {} \; BUT the problem is that these files that I want to compress are inside a directory with following format: ... (5 Replies)
Discussion started by: fretagi
5 Replies

9. Shell Programming and Scripting

Extract tar archive on remote server in another directory

HI Please suggest how to untar archive on remote sever. When im trying use regular command without any flags everything working fine: $( ssh <user>@<server> -n '. ~/.profile >/dev/null 2>&1 ; cd /path_1 ; copiedIVR_name=`ls -tr | tail -1` ; tar xvf $copiedIVR_name ' ) but i have to ... (1 Reply)
Discussion started by: BACya
1 Replies

10. UNIX for Dummies Questions & Answers

Extract tar archive on remote server in another directory

HI All Please suggest how to untar archive on remote sever. When im trying use regular command without any flags everything is working fine: $( ssh <user>@<server> -n '. ~/.profile >/dev/null 2>&1 ; cd /path_1 ; copiedIVR_name=`ls -tr | tail -1` ; tar xvf $copiedIVR_name ' ) but when im... (9 Replies)
Discussion started by: BACya
9 Replies
TAR(1)							      General Commands Manual							    TAR(1)

NAME
tar - The GNU version of the tar archiving utility SYNOPSIS
tar [ - ] A --catenate --concatenate | c --create | d --diff --compare | r --append | t --list | u --update | x -extract --get [ --atime- preserve ] [ -b, --block-size N ] [ -B, --read-full-blocks ] [ -C, --directory DIR ] [ --checkpoint ] [ -f, --file [HOSTNAME:]F ] [ --force-local ] [ -F, --info-script F --new-volume-script F ] [ -G, --incremental ] [ -g, --listed-incremental F ] [ -h, --dereference ] [ -i, --ignore-zeros ] [ -j, -I, --bzip ] [ --ignore-failed-read ] [ -k, --keep-old-files ] [ -K, --starting-file F ] [ -l, --one-file-sys- tem ] [ -L, --tape-length N ] [ -m, --modification-time ] [ -M, --multi-volume ] [ -N, --after-date DATE, --newer DATE ] [ -o, --old-ar- chive, --portability ] [ -O, --to-stdout ] [ -p, --same-permissions, --preserve-permissions ] [ -P, --absolute-paths ] [ --preserve ] [ -R, --record-number ] [ --remove-files ] [ -s, --same-order, --preserve-order ] [ --same-owner ] [ -S, --sparse ] [ -T, --files-from=F ] [ --null ] [ --totals ] [ -v, --verbose ] [ -V, --label NAME ] [ --version ] [ -w, --interactive, --confirmation ] [ -W, --verify ] [ --exclude FILE ] [ -X, --exclude-from FILE ] [ -Z, --compress, --uncompress ] [ -z, --gzip, --ungzip ] [ --use-compress-program PROG ] [ --block-compress ] [ -[0-7][lmh] ] filename1 [ filename2, ... filenameN ] directory1 [ directory2, ...directoryN ] DESCRIPTION
This manual page documents the GNU version of tar , an archiving program designed to store and extract files from an archive file known as a tarfile. A tarfile may be made on a tape drive, however, it is also common to write a tarfile to a normal file. The first argument to tar must be one of the options: Acdrtux, followed by any optional functions. The final arguments to tar are the names of the files or directories which should be archived. The use of a directory name always implies that the subdirectories below should be included in the archive. FUNCTION LETTERS
One of the following options must be used: -A, --catenate, --concatenate append tar files to an archive -c, --create create a new archive -d, --diff, --compare find differences between archive and file system --delete delete from the archive (not for use on mag tapes!) -r, --append append files to the end of an archive -t, --list list the contents of an archive -u, --update only append files that are newer than copy in archive -x, --extract, --get extract files from an archive OTHER OPTIONS
--atime-preserve don't change access times on dumped files -b, --block-size N block size of Nx512 bytes (default N=20) -B, --read-full-blocks reblock as we read (for reading 4.2BSD pipes) -C, --directory DIR change to directory DIR --checkpoint print directory names while reading the archive -f, --file [HOSTNAME:]F use archive file or device F (default /dev/rmt0) --force-local archive file is local even if has a colon -F, --info-script F --new-volume-script F run script at end of each tape (implies -M) -G, --incremental create/list/extract old GNU-format incremental backup -g, --listed-incremental F create/list/extract new GNU-format incremental backup -h, --dereference don't dump symlinks; dump the files they point to -i, --ignore-zeros ignore blocks of zeros in archive (normally mean EOF) -j, -I, --bzip filter the archive through bzip2. Note: -I is deprecated and may get a different meaning in the near future. --ignore-failed-read don't exit with non-zero status on unreadable files -k, --keep-old-files keep existing files; don't overwrite them from archive -K, --starting-file F begin at file F in the archive -l, --one-file-system stay in local file system when creating an archive -L, --tape-length N change tapes after writing N*1024 bytes -m, --modification-time don't extract file modified time -M, --multi-volume create/list/extract multi-volume archive -N, --after-date DATE, --newer DATE only store files newer than DATE -o, --old-archive, --portability write a V7 format archive, rather than ANSI format -O, --to-stdout extract files to standard output -p, --same-permissions, --preserve-permissions extract all protection information -P, --absolute-paths don't strip leading `/'s from file names --preserve like -p -s -R, --record-number show record number within archive with each message --remove-files remove files after adding them to the archive -s, --same-order, --preserve-order list of names to extract is sorted to match archive --same-owner create extracted files with the same ownership -S, --sparse handle sparse files efficiently -T, --files-from=F get names to extract or create from file F --null -T reads null-terminated names, disable -C --totals print total bytes written with --create -v, --verbose verbosely list files processed -V, --label NAME create archive with volume name NAME --version print tar program version number -w, --interactive, --confirmation ask for confirmation for every action -W, --verify attempt to verify the archive after writing it --exclude FILE exclude file FILE -X, --exclude-from FILE exclude files listed in FILE -Z, --compress, --uncompress filter the archive through compress -z, --gzip, --ungzip filter the archive through gzip --use-compress-program PROG filter the archive through PROG (which must accept -d) 30 October 2000 TAR(1)
All times are GMT -4. The time now is 11:06 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy