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:

  • 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

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.


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[@]}"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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