1

I'm trying to extract value after Colon in a string which will be integer value later to compare, but I see $ and \r after extracting, so I'm not able to compare integers

Ex:

count=$(echo "Bengaluru:10" | awk -F":" '{print $2}')

Result will be 10 only, but actually it's having additional hidden characters like $'10\r'

So I'm not able to compare this value with some other integer.

Please help me, how can i remove those values $ and \r

dlin
  • 3,740
  • 3
  • 29
  • 45
Murthi
  • 11
  • 1
  • One of your files (probably the script file) is in DOS/Windows format, and has a carriage return at the end of each line. See [this](https://stackoverflow.com/questions/22481278/syntax-error-invalid-arithmetic-operator-error-token-is) and [this](https://stackoverflow.com/questions/39527571/are-shell-scripts-sensitive-to-encoding-and-line-endings) on stackoverflow. – Gordon Davisson Apr 28 '20 at 05:20
  • 2
    Does this answer your question? [Invisible space when trying to remove file (but exclude all files in a list)?](https://askubuntu.com/questions/1183866/invisible-space-when-trying-to-remove-file-but-exclude-all-files-in-a-list) – Raffa May 02 '20 at 19:18

0 Answers0