Bash exercise

Hello,
please, how to read from a file when working on the bash shell

the exercise is as follows for more information:
create a script called "convertisseur" that allows you to convert an amount in Francs passed as an argument into Euros. The conversion rate will be contained in a file named Taux in the form: Taux: 6.55957. Remember to test if this file exists and is readable by your process. If not, your script should display an error and exit with a return code of 1
Configuration: Linux Suse Firefox 2.0

4 answers

  1. Contributor
    http://www-phase.c-strasbourg.fr/inform/linux/cours/user/cours.html
    http://www-phase.c-strasbourg.fr/inform/linux/cours/user/node12.html

    --
    @%$**¤!
    SPAM SPAM TROLL TROLL GODWIN POINT BANZAI !
    0
    1. I sketch a solution I'm not a pro in bash and I don't want to do your exercise :P
      place your convertisseur.sh script in the same directory as your taux.txt

      #!/bin/bash
      #converter

      function conversion () {
      let euros=$somme/$taux
      return euros
      }
      function assignrate {

      taux="more taux.txt | cut -d 'Rate :' " #selects the rate value from the taux.txt file
      if [ taux != ??]
      return 0
      }

      assignment ()
      echo "MACHINE CONVERTER BY THING"
      echo "What amount do you want to convert? (in Francs)"
      read somme

      assignment ()
      conversion (somme)

      echo "$somme"

      it must be full of errors: I don't remember how to pass parameters in a function in bash or how to check for the presence of the file... but it's always a lead ;)

      --
      omFg
      0
      1. Moderator
        For the first part
        [johand@horus]~ $echo $SHELL
        /bin/bash
        [johand@horus]~ $echo $(basename $SHELL)
        bash

        Then use test, [ ... etc
        --

        Gates vous a donné les fenêtres.
        GNU nous a donné toute la maison. (Alexandrin)
        0
        1. more 'the file name' to read a text file in bash.
          finally, for example, you also have vi, emacs, less, etc....

          good luck with your script :)
          0