home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / unix / shell / 5228 < prev    next >
Encoding:
Internet Message Format  |  1993-01-03  |  1.5 KB

  1. Path: sparky!uunet!pacsoft!mike
  2. From: mike@pacsoft.com (Mike Stefanik)
  3. Newsgroups: comp.unix.shell
  4. Subject: Re: need a bit of help in
  5. Message-ID: <1482@pacsoft.com>
  6. Date: 2 Jan 93 10:52:39 GMT
  7. References: <1993Jan1.195022.23031@mnemosyne.cs.du.edu>
  8. Organization: Pacific Software Group, Riverside, CA
  9. Lines: 29
  10.  
  11. In an article, rduta@nyx.cs.du.edu (Radu) writes:
  12. >1) I want a method of copying whole directories.  I'm used to the mac where
  13. >you can just drag folders form one dir to another and it moves it or
  14. >copies it.  I want something similar for unix.  The thing is that I
  15. >Haven't the slightest idea how to start.
  16.  
  17. If you want to copy a directory (as well as all of the subdirectories
  18. underneath it) you can use the find(1) and cpio(1) commands:
  19.  
  20.     ( cd /some/directory; find . -print ) | cpio -pdum /somewhere/new
  21.  
  22. If you want to rename or move directories around, try mv(1) or mvdir(1)
  23.  
  24. >2) I was wandering what is the easiest way to do a recursive grep, where
  25. >it searches all the files in all dirs.  I was thinking something along
  26. >the lines of "grep -R string *" but the "-R" flag is not an option.
  27.  
  28. Again, use the find(1) command in conjunction with xargs(1) and grep(1),
  29. such as:
  30.  
  31.     find . -type f -print | xargs -e grep "foo"
  32.  
  33. The "-type f" option tells find(1) to only return regular files (not
  34. directories, character or block special device files, etc.) and xargs(1)
  35. collects the filenames through the pipe and gives them to grep(1).
  36.  
  37. -- 
  38. Mike Stefanik  mike@pacsoft.com  ...!uunet!pacsoft!mike  (909) 681-2623
  39. Pacific Software Group, Riverside, CA
  40.