1
# Let's have a few test files
$ touch alpha beta
$ find ./*
./alpha
./beta

# Try find with filtering
$ find ./* -not -path './beta'
./alpha

# Now again, but save the command in a variable
$ F="find ./* -not -path './beta'"
$ echo "$F"
find ./* -not -path './beta'
$ $F
./alpha
./beta

Why did this happen? Something about quoting...?

Kombajn zbożowy
  • 8,755
  • 3
  • 28
  • 60
  • how about `F='find ./* -not -path "./beta"'`? btw backticks are discouraged. – SMA Mar 15 '18 at 13:55
  • This has the same result. `F='find ./* -not -path ./beta'` (without quotes) works correctly. However in my real case I would like to keep quotes somehow, because of a `*` in the filter. – Kombajn zbożowy Mar 15 '18 at 13:58
  • 1
    *Don't* store the command in a variable; define a function instead. – chepner Mar 15 '18 at 14:06

0 Answers0