PROXY  WHOIS  RQUOTE  TEXTS  SOFT  FOREX  BBOARD
 Music  Philosophy  Code  Literature  Russian

= ROOT|Technical|LinuxGazette|issue111.txt =

page 8 of 39




     But then, we're talking about us. :) "What do you mean, I can't jump off
     this cliff? It doesn't look all that high!"

ben@Fenrir:/tmp/foo$ for n in `seq 0 255`; do a=$(printf "\x`printf "%x" $n`");
 >"a${a}"; done
bash: a/: Is a directory
ben@Fenrir:/tmp/foo$ ls -b
a    a{     a\214  a\243  a\272  a\321  a\350  a\377  a\031  ad  aO
a`   a}     a\215  a\244  a\273  a\322  a\351  a\002  a\032  aD  ap
a^   a@     a\216  a\245  a\274  a\323  a\352  a\003  a\033  ae  aP
a~   a$     a\217  a\246  a\275  a\324  a\353  a\004  a\034  aE  aq
a<   a*     a\220  a\247  a\276  a\325  a\354  a\005  a\035  af  aQ
a=   a\\    a\221  a\250  a\277  a\326  a\355  a\006  a\036  aF  ar
a>   a&     a\222  a\251  a\300  a\327  a\356  a\a    a\037  ag  aR
a|   a#     a\223  a\252  a\301  a\330  a\357  a\b    a0     aG  as
a\   a%     a\224  a\253  a\302  a\331  a\360  a\t    a1     ah  aS
a_   a+     a\225  a\254  a\303  a\332  a\361  a\v    a2     aH  at
a-   a\001  a\226  a\255  a\304  a\333  a\362  a\f    a3     ai  aT
a,   a\200  a\227  a\256  a\305  a\334  a\363  a\r    a4     aI  au
a;   a\201  a\230  a\257  a\306  a\335  a\364  a\016  a5     aj  aU
a:   a\202  a\231  a\260  a\307  a\336  a\365  a\017  a6     aJ  av
a!   a\203  a\232  a\261  a\310  a\337  a\366  a\020  a7     ak  aV
a?   a\204  a\233  a\262  a\311  a\340  a\367  a\021  a8     aK  aw
a.   a\205  a\234  a\263  a\312  a\341  a\370  a\022  a9     al  aW
a'   a\206  a\235  a\264  a\313  a\342  a\371  a\023  aa     aL  ax
a"   a\207  a\236  a\265  a\314  a\343  a\372  a\024  aA     am  aX
a(   a\210  a\237  a\266  a\315  a\344  a\373  a\025  ab     aM  ay
a)   a\211  a\240  a\267  a\316  a\345  a\374  a\026  aB     an  aY
a[   a\212  a\241  a\270  a\317  a\346  a\375  a\027  ac     aN  az
a]   a\213  a\242  a\271  a\320  a\347  a\376  a\030  aC     ao  aZ
            ____________________________________________________

(?) tar and find

   From anonymous 

                                                Answered By: Thomas Adam 

   I'd like to tar up the contents of /var/www but I'd like to exclude a couple
   of directories. 

   I usually use 

   tar -zcvf www.tar.gz /var/www 

   but that does everything. 

   Idea's please 

     (!) [Thomas] Tar allows for you to have an exclude wildcard, rather than
     using a file from which exclusions are stored:

tar -czvf foo.tar.gz --exclude='*foo*' /var/www

     .. would allow you to specify a wildcard from which a list of files and/or
     directories could be excluded.

     Of course, if you're going to do that, this is where you really want to
     use find. Here's an example. I have a directory "tar" which has some
     files, and two directories:

[n6tadam@station tar]$ ls -lFh
total 20K
-rw-r--r--  1 n6tadam n6tadam    4 Jan 17 15:05 a
-rw-r--r--  1 n6tadam n6tadam   34 Jan 17 15:31 b
-rw-r--r--  1 n6tadam n6tadam   32 Jan 17 15:31 c
drwxr-xr-x  2 n6tadam n6tadam 4.0K Jan 17 15:05 foo/
drwxr-xr-x  2 n6tadam n6tadam 4.0K Jan 17 15:04 foo2/

     Now let us assume that I only want to tar the files a,b,c and exclude the
     ./foo{,2} stuff. What you really want is to preprocess your results with
     find. You can exclude one directory from a list. Here's an example:

find . -path './foo' -prune -o -print

     .. and note the syntax. The "." assumes that we're already in the same
     directory that we want the search to start from. In this case the "-path"
     option  to  find matches a pattern, treating "." and "/" as literal
     characters to match against. The -prune option excludes it (it assumes a
     -depth level, and doesn't descend into the path given. Then "-o" says to
     match everything else, and -print the results [1].

     On running that command:

[n6tadam@station tar]$ find . -path './foo' -prune -o -print
.
./a
./b
./c
./foo2
./foo2/d
./foo2/e
./foo2/f

     ... you'll see ./foo has been excluded. But how do you match more than one
     exclusion? I might not want ./foo or ./foo2 to be in my tar archive. Ok,
     here's how:

find . \( -path "./foo" -prune -o -path "./foo2" \) -prune -o -print
=8=

1|2|3|4|5|6|7| < PREV = PAGE 8 = NEXT > |9|10|11|12|13|14|15|16|17.39

UP TO ROOT | UP TO DIR | TO FIRST PAGE

Google
 


E-mail Facebook Google Digg del.icio.us BlinkList Fark Furl Ma.gnolia Netscape NewsVine Reddit Slashdot Spurl StumbleUpon Technorati YahooMyWeb LiveJournal Blogmarks TwitThis Live News2.ru BobrDobr.ru Memori.ru MoeMesto.ru

0.017911 wallclock secs ( 0.01 usr + 0.00 sys = 0.01 CPU)