Question

When I run

echo `nslookup 100.100.100.100`

in bash, it list all files (independent of the (non existing) ip adress). Is this an undocumented error, or what is going on?

I do realize that the echo is not needed here.

hpek@hpek:~/temp/nslookupTest$ touch fil1.txt
hpek@hpek:~/temp/nslookupTest$ touch fil2.txt
hpek@hpek:~/temp/nslookupTest$ touch fil3.txt
hpek@hpek:~/temp/nslookupTest$ echo `nslookup 100.100.100.100`
Server: 10.10.10.1 Address: 10.10.10.1#53 fil1.txt fil2.txt fil3.txt server can't find 100.100.100.100.in-addr.arpa.: NXDOMAIN
hpek@hpek:~/temp/nslookupTest$ 
Was it helpful?

Solution

The output of the nslookup command contains a star * which echo expands to the current dir's files (globbing). You can fix that by surrounding the command with quotes "

$ echo "$(nslookup 100.100.100.100)"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top