Ver Mensaje Individual
  #1 (permalink)  
Antiguo 04/06/2013, 19:08
darthradium
 
Fecha de Ingreso: noviembre-2009
Mensajes: 3
Antigüedad: 14 años, 6 meses
Puntos: 0
funciones en linux

Hola amigos se que a lo mejor piensan que esto es basico , pero si no pido ayuda me va a tomar mas tiempo encontrar el camino

tengo este codigo en shell, mi problema es que no lee las funciones que tengo hasta abajo, no se bien cual es la sintaxis, por fa me podrian ayudar??

tambien estoy buscando como llamar esas funciones desde otro archivo, como si fueran librerias..


Código:
#!/bin/bash

# Script to create menus and take action according to that selected menu item.
#
#
while :
  do
  clear
  echo "----------------------------------------------"
  echo " * * * * * * * Main Menu * * * * * * * * * * "
  echo "----------------------------------------------"
  echo "[1] Display"
  echo "[2] Add book and change"
  echo "[3] Delete data"
  echo "[4] Exit/stop"
  echo "----------------------------------------------"
  echo -n "Enter your menu choice [1-4]:"
  read yourch
  case $yourch in
    1) 
       echo "Please type the name of the book that you want display"; 
       sorting_book 

       read book
         ;;
       
 
    2) 
       echo "Please type the name of the book that you want add"; read adding
        add_book
;; 
       
    3) echo "Please Type the data that you want eliminate " read data
        erase_data 
                       

;;
    4) exit 0
       ;;
    *) echo "Opps!!! Please select choice 1,2,3 or 4"
       echo "Press a key. . ."
       read -n 1
       ;;
  esac
done


function sorting_book  {

        while :
          do
        clear
              echo "choose an option"
             echo "1 sort by name "
             echo "2 sort by price"
             echo "3 sort by year "
             echo "4 exit"

         read sorting
     case $sorting in
       1)
          grep -e '$book'.* library.txt | sort -t ""| awk -f "" '{print $1,"\t",$2}'
           ;;
       2)
          grep -e '$book'.* library.txt | sort -t ""| awk -f "" '{print $1,"\t",$2}'
           ;;       
       3)  
          grep -e '$book'.* library.txt | sort -t ""| awk -f "" '{print $1,"\t",$2}'
          ;; 
       4) exit 0
       ;;
    *) echo "Opps!!! Please select choice 1,2,3 or 4"
       echo "Press a key. . ."
       read -n 1
       ;;              
      esac
      done
              
                    }

function add_book {
      while :
          do
        clear
            echo "choose an option"
               
          
              echo "1 add book "
              echo "2 modify book"
              echo "3 exit"
        read adding 
     case $sorting in
          1)
                echo " construction"
           ;;       
     
          2)     
                 echo " construction"
           ;;
           3) exit 0
       ;;
           *) echo "Opps!!! Please select choice 1,2 or 3"
              echo "Press a key. . ."
              read -n 1
              ;;              
      esac
      done    
      
                  }

function erase_data {
              sed '/$data/d' library.txt

                      }