![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | 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. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| get files from multiple directories using FTP | amit1209 | Shell Programming and Scripting | 2 | 09-26-2007 10:39 AM |
| copy multiple files in different directories | ken2834 | UNIX for Dummies Questions & Answers | 3 | 03-25-2007 02:35 PM |
| gzipping large (2+ gb) files. | LordJezo | UNIX for Dummies Questions & Answers | 2 | 01-23-2007 11:11 AM |
| Search for files in multiple directories | ravikirankethe | UNIX for Dummies Questions & Answers | 7 | 10-29-2006 05:29 PM |
| FTP multiple files to different directories | abrd600 | Shell Programming and Scripting | 12 | 09-23-2004 08:56 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
cd to multiple directories and gzipping files within
I am working on a Korn shell script that will cd into multiple directories that are listed in a flat file and gzip the contents of each directory.
So far, this is what I have: 1) Find the 4 largest directories and place them into the file foo du -sk /some/directory/* | sort -rn | head -4 > foo Sample output: 390216 /first/Big/Directory 44441 /second/big/Foo Junk <---notice space after Foo 22873 /third/big/Dir 11817 /fourth/big/Dir_ectory 2) So that I can capture directories that may have a space in them, I am using the following: cat foo |\ sed -n 's/^[0-9]*\(.*\)$/\1/p' | sed 's/^[ \t]*//;s/[ \t]*$/"/' |\ sed -n 's/\(.*\)/"\1/p' > newfoo Sample output from above now appears as output below in file called newfoo: "/first/Big/Directory" "/second/big/Foo Junk" "/third/big/Dir" "fourth/big/Dir_ectory" Based on the file newfoo above, how can I cd into each of those directories and gzip the contents ? Everything I try ends up in messages basically stating that it can't find or stat the directories. Any suggestions or help would be appreciated. |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|