image
image

|


Go Back   macosx.com > Mac Help Forums > Unix & X11

Reply
 
Thread Tools
  #1  
Old September 20th, 2002, 05:16 PM
Gwailo's Avatar
B.A. Economics (Hon)
 
Join Date: Mar 2002
Location: Ottawa, Ontario
Posts: 330
Thanks: 0
Thanked 0 Times in 0 Posts
Gwailo is on a distinguished road
Unhappy CAT files in subfolders to a parent recursively?

I have thousands (no joke) of text files I need concatenated into a single file. They are all separated into hundreds of little sub-folders, and some in 2-3 levels deeper. The folder names and file names are all alphabetically sorted.

Is there any analogy to rm -r {directory_name} for cat {directory_name} > output_file_name.

Alternatyively is there a PERL or shell script I can eaisly write (assuming I know zero perl BTW) that could recursively put all the folders and files into one folder?

Alternatively I was looking at either TAR or GUNZIP flags that will prevent the archive's folder structure from being preserved on decompression. Theoretically I could compress this all and then decompress it so the paths are not preserved so all the files spilled back into one folder? I can't find the flag thouugh, don't know if it exists.

Anyway, any ideas?
__________________
//Gwailo//

iMac TFT 700MHz G4, 786 RAM, 40GB Internal
DVD-ROM/CD-RW 12x8x32
USB 64MB Flash Drive
Wacom Graphire2 Tablet
Epson 777i Colour Printer
Canon PowerShot S30 Digital Camera
JVC GR-DVF21 NTSC MiniDV Camera
Canon EOS Elan II (35mm)

"Like a beautiful flower full of colour and also fragrant, even so, fruitful are the fair words of one who practices them."
--54th Surtra, The Dhammapada

Reply With Quote
  #2  
Old September 20th, 2002, 06:08 PM
scruffy's Avatar
Notorious Olive Counter
 
Join Date: Dec 2000
Location: Soviet Canuckistan
Posts: 1,726
Thanks: 0
Thanked 0 Times in 0 Posts
scruffy is on a distinguished road
One way of doing it would be (fingers crossed that bbscript doesn't eat this):

find . -type f -exec cat {} >> ../a_big_file ";"

This will find all regular files in the current directory and all subdirectories, and concatenate them into a file called a_big_file, which will be in the parent directory.

You can put your big file anywhere you want, but don't put it in or below the current directory - then "find" will find the file, and concatenate it onto itself again and again and again, which you likely don't want...
__________________

What is the robbing of a bank compared to the founding of a bank?
-- Bertold Brecht
Reply With Quote
  #3  
Old September 20th, 2002, 09:00 PM
Gwailo's Avatar
B.A. Economics (Hon)
 
Join Date: Mar 2002
Location: Ottawa, Ontario
Posts: 330
Thanks: 0
Thanked 0 Times in 0 Posts
Gwailo is on a distinguished road
Oh yeah!!!

That was perfect! I tried it and it seems to have worked perfectly (I'm not even in the same city as my computer today, so using only the terminal to view my MASSIVE text file) but it seems good!

Thanks scruffy!
__________________
//Gwailo//

iMac TFT 700MHz G4, 786 RAM, 40GB Internal
DVD-ROM/CD-RW 12x8x32
USB 64MB Flash Drive
Wacom Graphire2 Tablet
Epson 777i Colour Printer
Canon PowerShot S30 Digital Camera
JVC GR-DVF21 NTSC MiniDV Camera
Canon EOS Elan II (35mm)

"Like a beautiful flower full of colour and also fragrant, even so, fruitful are the fair words of one who practices them."
--54th Surtra, The Dhammapada

Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
moving my itunes files to another location Numbers1820 Mac OS X System & Mac Software 2 December 20th, 2002 10:02 PM
Recursively delete files of one name in subfolders? michaelsanford Unix & X11 4 November 20th, 2002 08:48 AM
Native FTP program? bighairydog Apple News, Rumors & Discussion 17 November 30th, 2001 02:31 PM
Solution: OS X creating "." files on Samba shares dricci Apple News, Rumors & Discussion 0 November 21st, 2001 11:23 PM


All times are GMT -5. The time now is 09:22 AM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.