home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / unix_c / sysadmin / rename.sh < prev    next >
Encoding:
Text File  |  1989-03-21  |  1.5 KB  |  59 lines

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