[EMAIL PROTECTED] <[EMAIL PROTECTED]> [2002-12-30 13:30:56 +0100]:
> 
> J'ai un fichier "bobola" contenant la ligne suivante "99:12"
> Je veux r?cup?rer uniquement 12 pour faire des calculs arithm?tique avec la
> commande expr.
> Voici les commandes que j'effectue:

My French is poor, sorry.  I had a friend translate for me.  Roughly
translated as a file containing "99:12" and you have this problem.

>       toto=`grep "^99:" bobola | cut -d":" -f2`
>       expr $toto + 1
> Voici ce que j'obtiens :
>       expr: non-numeric argument

I cannot recreate a problem.

  echo 99:12 > bobola
  toto=`grep "^99:" bobola | cut -d":" -f2`
  expr $toto + 1
  13

However!  If I make an assumption that you have put a carriage return
at the end of the file because this is a MS-Windows formatted file
then your problem makes sense.

  printf "99:12\r\n" > bobola 
  toto=`grep "^99:" bobola | cut -d":" -f2`
  expr $toto + 1
  expr: non-numeric argument

Please check the exact contents of your file.

  od -c < bobola

You will certainly see other characters there after the number that is
getting placed in the second field after the :.

  od -c < bobola
  0000000   9   9   :   1   2  \r  \n
                               ^^ -- This is bad.
You can use tr to delete those.

  tr -d "\r" < bobola | od -c
  0000000   9   9   :   1   2  \n

Hope that helps.

Bob


_______________________________________________
Bug-textutils mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-textutils

Reply via email to