Waffles
Waffles

Reputation: 103

Why does find result in an empty new line within backticks?

For some reason, resolving a variable name within backticks and double quotes causes an empty new line.

search="randomsite";
res="`find /var/www -maxdepth 2 -mindepth 2 -type d -name '${search}'`";
echo $res

Upvotes: 0

Views: 54

Answers (1)

Mark Setchell
Mark Setchell

Reputation: 207560

Use $() rather than backticks - they are easier to read and nestable...

res=$(find /var/www -maxdepth 2 -mindepth 2 -type d -name "${search}")

Upvotes: 2

Related Questions