home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / unix / volume03 / rename < prev    next >
Encoding:
Internet Message Format  |  1988-09-11  |  1.1 KB

  1. From: genrad!amd!amdcad!phil (Phil Ngai)
  2. Subject: rename: a companion to restor
  3. Newsgroups: mod.sources
  4. Approved: jpn@panda.UUCP
  5.  
  6. Mod.sources:  Volume 3, Issue 36
  7. Submitted by: genrad!amd!amdcad!phil (Phil Ngai)
  8.  
  9. This is a shell script, not a shell archive.
  10.  
  11. #! /bin/sh
  12. # "rename" shell script
  13. # by Phil Ngai, 11/4/85
  14. # Moves files after V7 or Xenix style restor has left you with a
  15. # set of files with numeric names. It makes intermediate directories.
  16. # To use, first get a list of inodes and final pathname from dumpdir,
  17. # then edit out the names you don't want. In the top level directory,
  18. # feed the remaining lines to this script and feed its output to sh.
  19. # Sample expected input:
  20. #   11    /lib/uucp/dial.c
  21. #   13    /lib/tabset/3101
  22. #   30    /lib/atrun
  23. #  103    /lib/uucp/L.sys
  24. # Sample output:
  25. # mkdir ./lib
  26. # mkdir ./lib/uucp
  27. # mv 103    /lib/uucp/L.sys
  28. # mv  11    /lib/uucp/dial.c
  29. # mv  13    /lib/tabset/3101
  30. # mv  30    /lib/atrun
  31. while read in
  32. do
  33. set `echo $in`
  34. INODE=$1
  35. PATHNAME=$2
  36. FINALNAME=$PATHNAME
  37. OIFS=$IFS
  38. IFS=/
  39. set $PATHNAME
  40. IFS=$OIFS
  41. DIR=.
  42. while expr $# '>=' 2 > /dev/null
  43. do
  44. DIR=$DIR/$1
  45. echo mkdir $DIR
  46. shift
  47. done
  48. echo mv $INODE .$FINALNAME
  49. done \
  50. | sort | uniq
  51.  
  52.