Link to home
Start Free TrialLog in
Avatar of techpage
techpage

asked on

how to get data from a file

helloo..., I've been wondering... how do i write a shell script to write a data structure (name, age, phone number) into a file and recalls that data again from that file???
Avatar of bedot
bedot

1° to create (extract from an exercice of a student)
...
      echo "Nom : \c"
      read nom
do
  if [ -z "$nom" ] 2>/dev/null
  then
    clear
    break
  else
    echo "Prenom : \c                                       "
    read prenom
    echo "Ville : \c                                        "
    read ville
    echo "Telephone : \c"
    read tel
    nom=`echo $nom | tr ' ' '_'`
    prenom=`echo $prenom | tr ' ' '_'`
    ville=`echo $ville | tr ' ' '_'`
    nom=`echo $nom | tr ' ' '_'`
   # ajout dans fichier par printf pour unix 4.0
    printf '%-13.13s %-13.13s %-20.20s %-8.8s \n' $nom $prenom $ville $tel >> fi
chagent
   # ajout dans fichier par echo pour unix  3.2
   # echo $nom $prenom $ville $tel >> fichagent
   # echo " " >> fichagent
....

2° to print the content formatted

...

  cat ficagent | (while read nom prenom ville tel
    do
      printf '%1s %-13.13s %1s %-13.13s %1s %-20.20s %1s %-14.14s %1s \n' $b $nom $b $prenom $b $ville $b $tel $b
    done)

...

to search a line containin a criteria, use grep
Avatar of techpage

ASKER

Thanks.. but i've tried the source, it can't run... and I don't understand the language !! please make sure you give me the complete source.... *sob*...
Avatar of ozo
What shell languages do understand?
Sorry i can no more for you
ozo wanted to say what is the shell you are using ??, is it ksh ,csh ,sh ,... becuase each shell has it's own charactaristics.

ummm... i'm using sh... bourne shell !!!
ASKER CERTIFIED SOLUTION
Avatar of emmle
emmle

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This question was awarded, but never cleared due to the JSP-500 errors of that time.  It was "stuck" against userID -1 versus the intended expert whom you awarded.  This corrects that and the expert will now receive these points, all verified.

Please click on your Member Profile, select "View Question History" to navigate through any open or locked questions you may have to update and finalize them.
 
Thanks,
Moondancer
Moderator @ Experts Exchange