Advertisement
hackloper775

Ejemplomedioscripting

Dec 19th, 2012
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.69 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. clear
  4.  
  5. function dormir {
  6.  
  7. echo "Aguarde un segundo..."; sleep 1;
  8.  
  9. }
  10.  
  11. function carpeta {
  12.  
  13. echo -n "Crearemos una carpeta escriba el nombre que dese : "
  14.  
  15. read carpeta
  16. mi_carpeta=`echo $carpeta`
  17. }
  18.  
  19. function adios {
  20.  
  21. echo -e "Directorio acual $PWD\n""Listando..."; ls $PWD
  22.  
  23. echo -n "Borrar todo lo que se creo? n/s : "
  24.  
  25. read respuesta
  26.  
  27. case ${respuesta} in
  28.  
  29. s|S)
  30.  
  31. echo "Borrando archivos..."; dormir
  32. rm "${fichero_dos}" && rm "${fichero_uno}"
  33.  
  34. echo "Borrando carpeta..."; dormir
  35. cd ..; rmdir ${mi_carpeta}; autodestruccion
  36. ;;
  37. n|N)
  38.  
  39. echo "Buena eleccion ;P "; dormir; exit 1;
  40. ;;
  41.  
  42. esac
  43.  
  44. }
  45.  
  46. function autodestruccion {
  47.  
  48. echo -n "Borrar este script tambien s/n :"
  49.  
  50. read opcion
  51.  
  52. case ${opcion} in
  53.  
  54. s|S)
  55.  
  56. echo "Adios :("; rm $0
  57. ;;
  58. n|N)
  59.  
  60. echo "Buena elección :)"; exit 1;
  61. ;;
  62. *)
  63. echo "Ok";
  64. ;;
  65. esac
  66.  
  67. }
  68.  
  69. carpeta
  70.  
  71. while [ 0 ]; do
  72.  
  73. if [ ! -d "${mi_carpeta}" ]; then
  74.  
  75. mkdir "${mi_carpeta}" && cd "${mi_carpeta}"
  76.  
  77. echo "Directorio actual $PWD"
  78.  
  79. break
  80.  
  81. else
  82.  
  83. echo "Ya existe la carpeta y puede contener algo importante,elije otro nombre"
  84.  
  85. carpeta
  86.  
  87. fi
  88.  
  89. done
  90.  
  91.  
  92. echo -n "Nombre fichero uno: "
  93. read fichero_uno
  94. echo -n "Nombre fichero dos: "
  95. read fichero_dos
  96.  
  97. echo "Se creara el fichero dos del uno:"; dormir
  98.  
  99. while [[ ! -e "${fichero_uno}","${fichero_dos}" ]]
  100.  
  101. do
  102.                          
  103. if [ -e "${fichero_dos}" ]; then  
  104.  
  105. echo "${fichero_dos} existe"
  106.  
  107. dormir
  108.  
  109. cp ${fichero_dos} ${fichero_uno}
  110.  
  111. break
  112.  
  113. else
  114.  
  115. echo "${fichero_dos} no existe"; dormir
  116.  
  117. touch ${fichero_dos}
  118.  
  119. fi;
  120.  
  121. done
  122.  
  123. echo "Test completo."; echo -e "${fichero_uno} y ${fichero_dos} existen\n""Haciendo ls en $PWD"
  124. dormir
  125. ls
  126.  
  127. adios; clear
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement