Search code examples
bashhttpcarriage-return

bash: trouble getting file size from remote url


I am trying to get file size of remote url in the following manner:

I am trying the below command:

curl -sI $url | grep -i content-length | cut -d ' ' -f 2

Its giving 17857797\C-M

I dont understand why \C-M is adding


Solution

  • Append | dos2unix or | tr -d '\r' to remove carriage-return.