Copying all the .sh files into a tar file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Copying all the .sh files into a tar file
# 8  
Old 03-08-2013
You're right. I knew that. I just missed seeing in previous post.
# 9  
Old 03-11-2013
Hopefully, tar does not truncate on -c else xargs requires -u or -r. The tar man page is vague, but it is easy to check. Man Page for tar (opensolaris Section 1) - The UNIX and Linux Forums
Code:
Function Letters
       The function portion of the key is specified by one  of    the  following
       letters:
 
       c
 
       Create.  Writing begins at the beginning of the tarfile, instead of
       at the end.
 
       r
 
       Replace. The named files are written at the end of the  tarfile.  A
       file  created  with    extended headers must be updated with extended
       headers (see E flag under Function Modifiers). A file created with-
       out extended headers cannot be modified with extended headers.
 
       t
 
       Table of Contents. The names of the specified files are listed each
       time they occur in the tarfile. If no file argument    is  specified,
       the    names  of  all files and any associated extended attributes in
       the tarfile are listed. With the v  function  modifier,  additional
       information for the specified files is displayed.
 
       u
 
       Update.  The  named    files are written at the end of the tarfile if
       they are not already in the tarfile, or if they have been  modified
       since last written to that tarfile. An update can be rather slow. A
       tarfile created on a 5.x system cannot be updated on a 4.x  system.
       A  file created with extended headers must be updated with extended
       headers (see E flag under Function Modifiers). A file created with-
       out extended headers cannot be modified with extended headers.
 
       x
 
       Extract  or restore. The named files are extracted from the tarfile
       and written to the directory specified in the tarfile, relative  to
       the    current  directory.  Use  the relative path names of files and
       directories to be extracted.
 
       Absolute path names contained in the tar archive are unpacked using
       the    absolute path names, that is, the leading forward slash (/) is
       not stripped off.
 
       If a named file matches a directory whose contents has been written
       to the tarfile, this directory is recursively extracted. The owner,
       modification time, and mode are restored (if possible);  otherwise,
       to restore owner, you must be the super-user. Character-special and
       block-special devices (created by mknod(1M)) can only be  extracted
       by  the  super-user.  If  no file argument is specified, the entire
       content of the tarfile is extracted. If the tarfile    contains  sev-
       eral  files    with the same name, each file is written to the appro-
       priate directory, overwriting the previous one. Filename  substitu-
       tion  wildcards  cannot  be    used for extracting files from the ar-
       chive. Rather, use a command of the form:
 
         tar xvf ... /dev/rmt/0 `tar tf ... /dev/rmt/0 | grep 'pattern' `
 
       When extracting tapes created with the r or u functions, directory mod-
       ification  times  can not be set correctly. These same functions cannot
       be used with many tape drives due to tape drive limitations such as the
       absence of backspace or append capabilities.
 
       When  using  the  r,  u, or x functions or the X function modifier, the
       named files must match exactly the corresponding files in the  tarfile.
       For  example,  to  extract ./thisfile, you must specify ./thisfile, and
       not thisfile. The t function displays how each file was archived.
 
There is always this, if the line is not too long:
 
$ tar cf xxxx.tar `find ...`

# 10  
Old 03-11-2013
Abusing pax's substitution capability:
Code:
pax -w -s '/^.*[^h]$//' -s '/^.*[^s]h$//' -s '/^.*[^.]sh$//' -s '/^sh$//' . > sh_scripts.tar

For those who live in the real world, use find instead.

Regards,
Alister
# 11  
Old 03-11-2013
-x xustar ?
# 12  
Old 03-11-2013
Quote:
Originally Posted by DGPickett
-x xustar ?
I have never seen an implementation that does not default to ustar, but being explicit is good futureproofing.

Regards,
Alister
# 13  
Old 03-11-2013
# 14  
Old 03-11-2013
Quote:
Originally Posted by DGPickett
From your link:
Quote:
The supported archive formats are automatically detected on input. The
default output archive format is tar(1).
Perhaps you misunderstood the following:
Quote:
In copy mode, if no -x format is specified, pax behaves
as if -x pax were specified.
That does not involve creating an archive. It's for internal purposes when replicating hierarchies, for example, where the pax format has fewer restrictions on pathnames than cpio and tar.

Regards,
Alister
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Copying files to a directory, renaming it if a file with the same name already exists

Hi All, I need to copy files from one directory to another with the files to be renamed while copying if a file with the same name already exists in the target directory. THanks, Dev (2 Replies)
Discussion started by: dev.devil.1983
2 Replies

2. Shell Programming and Scripting

Copying a file to multiple other files using a text file as input

Hello, I have a file called COMPLIST as follows that contains 4 digit numbers.0002 0003 0010 0013 0015 0016 0022 0023 0024 0025 0027 0030 0031 0032 0033 0035 0038 0041 (3 Replies)
Discussion started by: sph90457
3 Replies

3. Shell Programming and Scripting

To tar the content while copying files

Any idea on how we can tar the content while copying the files from one location to another location using the bash script. (2 Replies)
Discussion started by: gsiva
2 Replies

4. Shell Programming and Scripting

Copying List of Files Under Different File Names ?!

Hi to all here , Excuse me for the lamer question but I need UNIX command for copying List of Files Under Different File Names ! for example I have this list: new_001.jpg new_002.jpg new_003.jpg ..... I want to copy all files that start with "new_" to the same directory but under... (7 Replies)
Discussion started by: boboweb_
7 Replies

5. Shell Programming and Scripting

tar command to explore multiple layers of tar and tar.gz files

Hi all, I have a tar file and inside that tar file is a folder with additional tar.gz files. What I want to do is look inside the first tar file and then find the second tar file I'm looking for, look inside that tar.gz file to find a certain directory. I'm encountering issues by trying to... (1 Reply)
Discussion started by: bashnewbee
1 Replies

6. UNIX for Dummies Questions & Answers

No such file or directory error while copying files

Hi, I need to copy files from one dir to another dir. The list of filesnames to be moved are in a file called files2cp.log Script: #!/bin/ksh exec 0</home/amdocs/files2cp.log while read LINE do cp -i /iccs33/attach/"$LINE" /iccs30/attach/"$LINE" done The output is "No such... (6 Replies)
Discussion started by: srinirsr
6 Replies

7. Shell Programming and Scripting

Perl-opening a file then copying files

Good morning guys!! Im still practicing with Perl and now Im trying to open a file, and copy its contents to another file. Them I want to remeove the information out of the orginal file after it is copied over. The flow should be messages-->messages1-->messages2. Kind of like a log... (1 Reply)
Discussion started by: bigben1220
1 Replies

8. UNIX for Dummies Questions & Answers

tar -cvf test.tar `find . -mtime -1 -type f` only tar 1 file

Hi all, 4 files are returned when i issue 'find . -mtime -1 -type f -ls'. ./ora_475244.aud ./ora_671958.aud ./ora_934052.aud ./ora_934050.aud However, when I issued the below command: tar -cvf test.tar `find . -mtime -1 -type f`, the tar file only contains the 1st file -... (2 Replies)
Discussion started by: ahSher
2 Replies

9. AIX

copying files to a remote aix server using tar!

Hi, I am using AIX 5.2, and I want to copy some files from one server to a remote server using tar command. Can anybody tell me exact command? Thanks. Aqeel (2 Replies)
Discussion started by: system-admin
2 Replies

10. UNIX for Dummies Questions & Answers

Copying files from file to another

How do I copy one file from one unix file to another??? I'm new at this, please help.. (3 Replies)
Discussion started by: Tevin
3 Replies
Login or Register to Ask a Question