The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM
Home Forums Register Rules & FAQ Members List Arcade Search Today's Posts Mark Forums Read


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!


Other UNIX.COM Threads You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
redirect the grep output into the variable mail2sant Shell Programming and Scripting 1 04-08-2008 06:46 AM
redirect output of dos2unix command nrbhole Shell Programming and Scripting 4 01-25-2008 05:30 AM
awk redirect output to shell variable dhinge Shell Programming and Scripting 3 12-09-2006 08:11 AM
Redirect Output In Variable ZINGARO UNIX for Dummies Questions & Answers 1 08-02-2006 03:56 AM
Redirect from Variable to command line?? ugh UNIX for Dummies Questions & Answers 8 03-28-2006 07:31 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-22-2005
Registered User
 

Join Date: Jun 2005
Posts: 15
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
redirect command output to variable

Hi,

I am looking for a way to redirect the result from a command into a variable.
This is the scenario.

Using the find command I will be getting multiple records/lines back.
Here is the command I am using:

find /”path”/ -name nohup.out –print

This now is giving me the paths and file names back as a record/line.
Ex.
/”path1”/ nohup.out
/”path2”/ nohup.out
/”path3”/ nohup.out

I would like to pass these records/lines into a variable line for line and then use the variable line for line in another command echo.

The result would be that I will echo info into the nohup.out files.

Please will you assist me with this?

Thank you for your assistance.

Hugo
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 06-22-2005
Registered User
 

Join Date: Oct 2003
Location: United Kingdom
Posts: 37
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
You could try

for variable in $(find) do
array[counter]=variable
done

You then have an associative array that contains all the values. Obviously you would need to set up a counter for the subscript.

If you're interested in dynamically creating variable names, please note one of my earlier posts on this subject. It is incredibly powerful, especially when using common code modules in shell scripting:

www.unix.com - Faux hash table

Last edited by Simerian : 06-22-2005 at 05:37 AM.
Reply With Quote
Google UNIX.COM
Reply



Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 09:55 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger

Search Engine Optimization by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102