home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / ultrix / 5816 < prev    next >
Encoding:
Text File  |  1992-07-21  |  1.2 KB  |  39 lines

  1. Newsgroups: comp.unix.ultrix
  2. Path: sparky!uunet!haven.umd.edu!decuac!hussar.dco.dec.com!mjr
  3. From: mjr@hussar.dco.dec.com (Marcus J. "will do TCP/IP for food" Ranum)
  4. Subject: Re: How do you cat together files without getting subdirs?
  5. Message-ID: <1992Jul22.010325.27235@decuac.dec.com>
  6. Sender: news@decuac.dec.com (USENET News System)
  7. Nntp-Posting-Host: hussar.dco.dec.com
  8. Organization: Digital Equipment Corporation, Washington ULTRIX Resource Center
  9. References: <110593@muvms3.bitnet>
  10. Date: Wed, 22 Jul 1992 01:03:25 GMT
  11. Lines: 26
  12.  
  13. >I want to cat a pile of text files together. They are all in the same
  14. >directory.  However there are also subdirectories in there too.  How can I
  15. >wildcard to get the files, but not the subdir entries?
  16.  
  17. This will cat all files in a directory and its subdirectories:
  18.  
  19.     (find . -type f -print | xargs cat )
  20.  
  21. The parentheses run it in a subshell, so its output in turn can be
  22. redirected:
  23.  
  24.     (find . -type f -print | xargs cat ) | grep seaotters
  25.     (find . -type f -print | xargs cat ) > /tmp/output
  26.  
  27. To get all files in a directory that are not subdirectories or devices:
  28.  
  29.     (for a in *; do
  30.         if [ -f "$a" ]; then
  31.             cat $a
  32.         fi
  33.     done) > /tmp/output
  34.  
  35.  
  36. There is probably some way to do this with a single grotty line of perl...
  37.  
  38. mjr
  39.