LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-30-2012, 01:21 AM   #1
rohan1977
LQ Newbie
 
Registered: Apr 2012
Posts: 1

Rep: Reputation: Disabled
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

Last edited by rohan1977; 04-30-2012 at 01:28 AM.
 
Old 04-30-2012, 01:35 AM   #2
Diantre
Member
 
Registered: Jun 2011
Distribution: Slackware
Posts: 515

Rep: Reputation: 234Reputation: 234Reputation: 234
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Output of ps command - can't find file kurk Linux - General 4 04-29-2010 12:44 PM
Piping Output of a Command Like Find cipher7836 Linux - Newbie 13 08-16-2009 03:41 AM
Perl Script command to unset ORA_NLS environment varaible rajaniyer123 Solaris / OpenSolaris 3 06-04-2009 05:30 AM
find with -exec: no command output David the H. Linux - Software 5 01-03-2008 01:53 AM
Assign command output to a varible. wilku Linux - Newbie 3 03-26-2005 11:56 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration