LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Redirecting command output to input of another command (https://www.linuxquestions.org/questions/linux-newbie-8/redirecting-command-output-to-input-of-another-command-889552/)

mightymouse2045 07-02-2011 11:29 AM

Redirecting command output to input of another command
 
HI guys,

Sorry I can't wrap my head around this one. So hopefully someone can help.

I want to run

gsettings list-schemas (which return a list of about 100 names separated by spaces)

and somehow direct each name one at a time as the input to this command:

gsettings list-recursively

I've tried it with awk, and standard | piping and also as a string variable strvar=$(gsettings list-schemas) and using the $strvar as the input but I am missing something in between I'm sure like for - while or proper syntax of awk etc

Can someone help as I would like to be able to save the output of each schema entry to make it easy searching etc

Thanks heaps in advance :)

raevin 07-02-2011 11:32 AM

Not @ my computer to test but you might be able to use shift along with awk. Id google awk shift entries to see if anything comes up.

coralfang 07-02-2011 12:07 PM

This script should do the job:

Code:

#!/bin/sh
for i in `gsettings list-schemas`; do
        gsettings list-recursively $i
done

Or as a one liner:
Code:

for i in `gsettings list-schemas`; do gsettings list-recursively $i; done

mightymouse2045 07-02-2011 12:28 PM

Thanks heaps man that's just what I was after :D


All times are GMT -5. The time now is 02:25 PM.