LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Assign find command output to a varaible (http://www.linuxquestions.org/questions/linux-newbie-8/assign-find-command-output-to-a-varaible-942486/)

rohan1977 04-30-2012 01:21 AM

Assign find command output to a varaible
 
Hi Im trying to assign a find command output to a varaible but im unable to do so
Can someone please help me solve it
<
Quote:


#!/bin/bash


array=(vnbh5-apcpu 05-apcpu)
for item in ${array[*]}
do
echo $item
fileslist= find /nmis/ -name "$item.xml" -type f
echo the file is at $fileslist
done
Thanks

Diantre 04-30-2012 01:35 AM

Try using this:

Code:

fileslist=$(find /nmis/ -name "$item.xml" -type f)
Keep in mind that with each iteration of the for loop the contents of $fileslist are replaced.


All times are GMT -5. The time now is 03:54 AM.