Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The result of the following script:

results=$(find -iname "*.mp4")
echo $results;

is something like:

file1 file2 file3

How do I pass the results of the find command to a variable, as it is shown when I run the following command in terminal:

find -iname "*.mp4"

which prints:

share|improve this question
How do you want to use this result? – Mat Nov 3 '12 at 7:48
@Mat I want to pass the results to zenity --text-info – Omid Nov 3 '12 at 7:51
up vote 3 down vote accepted

Instead of doing echo $results do echo "$results".


The difference between the 2 is that in the 1st case echo receives many parameters and in the 2nd case it receives only one parameter. This is because variable substitution occurs before parameter parsing.

share|improve this answer

Try this, an example on zenity lists, it read the result from find, and generate an array, then pass on to zenity:


while IFS= read -d $'\0' -r file ; do
    List=("${List[@]}" "$file")
done < <(find . -iname '*.mp4' -print0)

zenity --list --column "Item" "${List[@]}"
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.