hervasiop12345

cuenta_tipos_2

Jan 21st, 2012
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.06 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. function ficheros {
  4.    numficheros=`file *| grep -i "$1" | wc -l`
  5.    contador=1
  6.    echo -e "   -Hay $numficheros ficheros de "$2":`file * | grep -i "$1" | cut -d ":" -f 1 |
  7.   while read line
  8.   do          
  9.      if [ "$numficheros" -ne "$contador" ]
  10.      then
  11.         echo -n "$line, "
  12.      else
  13.         echo "$line"
  14.      fi
  15.      let contador=contador+1
  16.   done`"  
  17. }
  18.  
  19. if [ "$#" -eq "1" ]
  20. then
  21.    if test -d "$1" 2> /dev/null && test -d "$1" 2> /dev/null
  22.    then
  23.       directorio=$1
  24.    else
  25.       echo "./shell1 [directorio_permisos_lectura]"
  26.       exit 1
  27.    fi
  28. elif [ "$#" -eq "0" ]
  29. then
  30.    directorio=$PWD  
  31. else
  32.    echo "./shell1 [directorio_permisos_lectura]"
  33.    exit 1
  34. fi
  35.  
  36. cd $directorio
  37. echo "La clasificación de ficheros del directorio $directorio es:"
  38. tipo="text"
  39. tcompleto="texto"
  40. ficheros $tipo $tcompleto
  41. tipo="device"
  42. tcompleto="dispositivo"
  43. ficheros $tipo $tcompleto
  44. tipo="directory"
  45. tcompleto="directorio"
  46. ficheros $tipo $tcompleto
  47. tipo="executable"
  48. tcompleto="tipo ejecutable"
  49. ficheros $tipo $tcompleto
Advertisement
Add Comment
Please, Sign In to add comment