Command returns ": No such file or directory" error due to CRLF

Solution Verified - Updated -

Issue

grep sosreport test.txt | sed s/\'//g | awk '{print $2}' | xargs ls -l returns ": No such file or directory" even if a file exists.

# grep sosreport sosreport1.txt | sed s/\'//g | awk '{print $2}'

sosreport
version

# grep sosreport test.txt | sed s/\'//g | awk '{print $2}' | xargs ls -l
: No such file or directory
: No such file or directory
# ls -l sosreport
-rw-r--r-- 1 root root 0 May 19 14:06 sosreport

Also normally, we get "ls: cannot access xxx: No such file or directory" but not ": No such file or directory" if a file or directory doesn't exist.

Environment

  • Red Hat Enterprise Linux ALL

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content