bug-textutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: BUG SUR LA COMMANDE CUT SOUS BASH


From: Bob Proulx
Subject: Re: BUG SUR LA COMMANDE CUT SOUS BASH
Date: Tue, 31 Dec 2002 19:51:31 -0700
User-agent: Mutt/1.4i

address@hidden <address@hidden> [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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]