Bash test yields "echo: command not found"

Well, something funny happens all of a sudden. This test

for i in `cat /mnt/usb/liste.txt `; do [ -f /mnt/usb/lsdvd.xml/$i ] || echo $i; done

it is used to work perfectly (for each entry in the liste.txt file try to find the corresponding directory, type the name if it is not found) and is used to get the names of the missing directories. Now this command gives

 echo: command not found
 echo: command not found
 echo: command not found
(...)

I tried to use [[...]] and "test" instead of "[..]", but to no avail.

Any ideas what could happen to my favorite bash while I was not looking :)?

Thank you Christian.

Edit (set -x output):

(...)
+ for i in '`cat /mnt/usb/liste.txt`'
+ '[' -f /mnt/usb/lsdvd.xml/THE_GHOST_WRITER.lsdvd.xml ']'
+ for i in '`cat /mnt/usb/liste.txt`'
+ '[' -f /mnt/usb/lsdvd.xml/THE_IMAGINARIUM_OF_DOCTOR_PARNASSUS.lsdvd.xml ']'
+ for i in '`cat /mnt/usb/liste.txt`'
+ '[' -f /mnt/usb/lsdvd.xml/THE_INFORMANT.lsdvd.xml ']'
+ for i in '`cat /mnt/usb/liste.txt`'
+ '[' -f /mnt/usb/lsdvd.xml/THE_INTERNATIONAL.lsdvd.xml ']'
+ for i in '`cat /mnt/usb/liste.txt`'
+ '[' -f /mnt/usb/lsdvd.xml/THE_MEN_WHO_STARE_AT_GOATS.lsdvd.xml ']'
+ for i in '`cat /mnt/usb/liste.txt`'
+ '[' -f /mnt/usb/lsdvd.xml/THE_OTHER_MAN.lsdvd.xml ']'
+ for i in '`cat /mnt/usb/liste.txt`'
+ '[' -f /mnt/usb/lsdvd.xml/THE_QUEEN.lsdvd.xml ']'
+ for i in '`cat /mnt/usb/liste.txt`'
+ '[' -f /mnt/usb/lsdvd.xml/THE_READER.lsdvd.xml ']'
+ for i in '`cat /mnt/usb/liste.txt`'
+ '[' -f /mnt/usb/lsdvd.xml/THE_REBOUND.lsdvd.xml ']'
+ $'\302\240echo' THE_REBOUND
+ '[' -x /usr/lib/command-not-found ']'
+ /usr/bin/python /usr/lib/command-not-found -- $'\302\240echo'
 echo: command not found
+ return 127
(...)
+3
source share
4 answers

If you look carefully, you will see its print:

 echo: command not found

with leading space, not:

echo: command not found

set -x makes this much clearer when it prints:

$'\302\240echo' THE_REBOUND

0302 0240 UTF-8 .

| echo .


, Mac, , Option Space.

Vim, , listchars. :

set listchars+=nbsp:% list

. Vim .

Linux - Compose Space Space Ctrl + Shift + u a 0, , , .


, , UTF-8, UTF-8 UTF-8 .

Python:

>>> import unicodedata
>>> unicodedata.name('\302\240'.decode('utf-8'))
'NO-BREAK SPACE'
+12

: - , , , $'\302\240echo': . , .

. , , cat:

while IFS= read -r; do [ -f "/mnt/usb/lsdvd.xml/$REPLY" ] || echo "$REPLY"; done < /mnt/usb/liste.txt
+2

:

for i in `cat /mnt/usb/liste.txt `; do
    echo $i
done

, - (, , ..)? , , .

, if :

for i in `cat /mnt/usb/liste.txt `; do
    if [ ! -f /mnt/usb/lsdvd.xml/$i ]; then
        echo $i
    fi
done
0

:

for f in $(< d2.lst); do [ -f ./d2/$f ] || echo $f ; done

Just my own file names, directories and the proposed construction of $ (...) instead of backlinks and with <instead of a cat.

Maybe the dos / windows line in your list? View it with less.

0
source

All Articles