From: Janis Papanagnou on
Lao Ming wrote:
> On Dec 16, 11:14 pm, jellybean stonerfish <stonerf...(a)geocities.com>
> wrote:
>> On Wed, 16 Dec 2009 22:08:22 -0800, Lao Ming wrote:
>>> I want to copy all of my C code in one directory hierarchy into one
>>> compressed file. Excepting those with a name containing "chart".
>>> This is how I began:
>>> find . -name "*.c" |grep -v "chart" | {
>>> while IFS='
>>> ' read file
>>> do
>>> At this point, I imagine that I would add one file at a time in the loop
>>> to tar and then when the loop finishes, gzip the tar file. But I'm
>>> unsure about how to proceed.
>>> thanks.
>>> Lao-Ming
>> If your tar supports "--exclude=" then
>>
>> tar -vczf /path/to/save.tar.gz --exclude='*chart*' *.c

tar -vczf /path/to/save.tar.gz --exclude='*chart*' "*.c"

>
> Thanks -- this would be perfect except that it only tarred and gzipped
> one file that it found in the current directory and not all the files
> from the entire hierarchy (which there are many). I used it exactly
> as specified except, of course, the path to the output file.

Above should correct it.

Without quotes the shell expands *.c to the matching files in the current
directory and find finds only those files whose names match the expanded
filename.

Janis
From: Lao Ming on
On Dec 16, 11:49 pm, Stephane CHAZELAS <stephane_chaze...(a)yahoo.fr>
wrote:
> 2009-12-16, 22:08(-08), Lao Ming:> I want to copy all of my C code in one directory hierarchy
> > into one compressed file.  Excepting those with a name containing
> > "chart".
>
> > This is how I began:
>
> >    find . -name "*.c"  |grep -v "chart" |
> >    {
> >    while IFS='
> > ' read file
> >    do
>
> > At this point, I imagine that I would add one file at a time
> > in the loop to tar and then when the loop finishes, gzip the tar file.
> > But I'm unsure about how to proceed.
>
> [...]
>
> find . -name '*.c' ! -name '*chart*' -type f |
>   pax -w | compress > x.tar.Z
>
> --
> Stéphane

This works perfectly. Thanks a bunch, Stéphane!
I used gzip instead and it works too.
Then I used this to list the included files:

gzip -dc 091217.tar.gz |strings |grep "^\..*c$"

There's probably a better way.
From: Stephane CHAZELAS on
2009-12-17, 13:04(-08), Lao Ming:
[...]
> Then I used this to list the included files:
>
> gzip -dc 091217.tar.gz |strings |grep "^\..*c$"
>
> There's probably a better way.

gunzip < 091217.tar.gz | pax

Or:

gunzip < 091217.tar.gz | tar tf -

Or with some tar implementations:

tar ztf 091217.tar.gz

or even:

tar tf 091217.tar.gz

See the tar(1) and pax(1) man pages for details.

--
St�phane
From: jellybean stonerfish on
On Thu, 17 Dec 2009 12:36:22 -0800, Lao Ming wrote:

> On Dec 16, 11:14 pm, jellybean stonerfish <stonerf...(a)geocities.com>
> wrote:
>> On Wed, 16 Dec 2009 22:08:22 -0800, Lao Ming wrote:
>> > I want to copy all of my C code in one directory hierarchy into one
>> > compressed file.  Excepting those with a name containing "chart".
>>
>> > This is how I began:
>>
>> >    find . -name "*.c"  |grep -v "chart" | { while IFS='
>> > ' read file
>> >    do
>>
>> > At this point, I imagine that I would add one file at a time in the
>> > loop to tar and then when the loop finishes, gzip the tar file. But
>> > I'm unsure about how to proceed.
>>
>> > thanks.
>>
>> > Lao-Ming
>>
>> If your tar supports "--exclude=" then
>>
>> tar -vczf /path/to/save.tar.gz --exclude='*chart*' *.c
>
> Thanks -- this would be perfect except that it only tarred and gzipped
> one file that it found in the current directory and not all the files
> from the entire hierarchy (which there are many). I used it exactly as
> specified except, of course, the path to the output file.

You can make a file that has a list of filenames, and tell tar with
the "-T" option to tar the files in the list.

You can use find, and have it select the '.c' files and exclude files
with "chart"
find . -iname '*.c' -not -iname '*chart*'

First  |  Prev  | 
Pages: 1 2
Prev: split in memory
Next: Bash Zenity help