4

Check if filename exist from inline command

view full story
linux-howto

http://unix.stackexchange.com – I have a file named input.txt with this contents: ... FILE "Edie - Realities.txt" TXT ... And I want to read it, then strip filename path from line that starts with FILE, and check if it exists, so: [ -f $(cat input.txt | grep FILE | grep -o "\".*\"") ] && echo "exist" || echo "does not exist" but this outputs: [: too many arguments does not exist If I run: echo $(cat input.txt | grep FILE | grep -o "\".*\"") I get what I expected: "Edie - Realities.txt" So why is this, or how can I solve this problem? (HowTos)