Re: redirecting stdout in script
From: Frank Chiavoni (Frank.Chiavoni_at_OIT.STATE.NJ.US)
Date: 08/03/05
- Previous message: Vincent D'Antonio: "Re: Off Topic -- TSM"
- In reply to: Shawn Bierman: "redirecting stdout in script"
- Next in thread: Frank Chiavoni: "Re: redirecting stdout in script"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 3 Aug 2005 10:33:31 -0400 To: aix-l@Princeton.EDU
Shawn Bierman wrote:
> I would like to redirect the output of a command in my script to the the input of a function in the same script. Is this possible?
>
>
> example:
>
> *- snip *-
> #!/bin/ksh
>
> myprint () {
> print "myoutput: $*"
> }
>
> ls file* | myprint
> *- snip *-
>
> Any ideas on how to execute this or suggestions on a better way?
>
> I want to control the output of the command so I can format it like this:
>
> myoutput: file1
> myoutput: file2
> myoutput: file3
> ...
>
> thanks.
> -shawn
Maybe...
#!/bin/ksh
myprint () {
eval "$x" |
while read y
do
print "myoutput: $y"
done
}
x='ls mdisk*'
myprint
Frank
- Previous message: Vincent D'Antonio: "Re: Off Topic -- TSM"
- In reply to: Shawn Bierman: "redirecting stdout in script"
- Next in thread: Frank Chiavoni: "Re: redirecting stdout in script"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|