home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.ultrix
- Path: sparky!uunet!haven.umd.edu!decuac!hussar.dco.dec.com!mjr
- From: mjr@hussar.dco.dec.com (Marcus J. "will do TCP/IP for food" Ranum)
- Subject: Re: How do you cat together files without getting subdirs?
- Message-ID: <1992Jul22.010325.27235@decuac.dec.com>
- Sender: news@decuac.dec.com (USENET News System)
- Nntp-Posting-Host: hussar.dco.dec.com
- Organization: Digital Equipment Corporation, Washington ULTRIX Resource Center
- References: <110593@muvms3.bitnet>
- Date: Wed, 22 Jul 1992 01:03:25 GMT
- Lines: 26
-
- >I want to cat a pile of text files together. They are all in the same
- >directory. However there are also subdirectories in there too. How can I
- >wildcard to get the files, but not the subdir entries?
-
- This will cat all files in a directory and its subdirectories:
-
- (find . -type f -print | xargs cat )
-
- The parentheses run it in a subshell, so its output in turn can be
- redirected:
-
- (find . -type f -print | xargs cat ) | grep seaotters
- (find . -type f -print | xargs cat ) > /tmp/output
-
- To get all files in a directory that are not subdirectories or devices:
-
- (for a in *; do
- if [ -f "$a" ]; then
- cat $a
- fi
- done) > /tmp/output
-
-
- There is probably some way to do this with a single grotty line of perl...
-
- mjr
-