[aklug] Fwd: Re: Re: Fwd: Re: Re: noob scripting question -- file input/output

From: <jim@macdonald.org>
Date: Fri Oct 31 2008 - 17:47:27 AKDT

 just forwarding this to the list so they can make fun of me if I am asking
=stupid questions.

On Oct 31, 2008, jim@macdonald.org wrote: wouldn't this work?
foo datain >output.txt

either way I don't think the second= cat is nessessary you can just redirect
the output of foo straight to anot= her file name.

if datain is a txt file and not an executab= le script

datain >add >dataout

will not work=

but

foo datain >dataout

should.
is this Trusted Solaris?

On Oct 31, 2008, choward@indicium.us wrote: jim@macdonald.org wrote:
> For some reason my email client puked on the send
>Wh= at I was say=3D ing was that typically you can just pipe the output of
one> command into ano=3D ther. Lets say you want to capture the stdout= and
stderr
>toa file:
>$> df -h 2>&1 >outpu= t.out
>
>Now lets say you wan=3D t to output the results o= f "df -h" to grep so you
can
>just see the inf=3D ormation for /et= c
>
>$> df -h 2>&1 |grep etc
>
>= N=3D ow lets say you want to just grab the free space of /etc/ from df
-h>$> df -h |grep etc| cut -d' ' -f3
>
>note th= e fieldnumber =3D (f3) might be wrong, I am writing this on a
windows
= >machine and can't check=3D the output but you get the point.
>=
>either way you do it there sh=3D ould not be a reason you have t= o cat the
>resulting text file of a command t=3D o get it to input= to another
command.
>you should be able to just run =3D the comm= and and redirect the stdout
through
>a pipe to the next command. >the only real useful thing I have found for
catis to pipe the co= n=3D tents of
>two files together. Thusly:
>
>cat= file1 file2 >file3
>else use grep because chances are you are = looking for a particul=3D ar
entry
>ina file anyway.
>>Hope this helps.
>
>PS. one=3D other thing that y= ou can do with the 2>&1 syntax is output the
>stdo=3Dut and= stderr to a text file AND output it to the tty so you can
see
>th= eer=3D rors in real time and the go back and grep for the particulars
later=
>=3D
>$>df -h 2>&1 |tee error.out
>=
>Jim
>
>
>
>On Oct 31, 2008, ro= yce@alaska.net wrote: Good stuff - intended to rep=3D
ly
>all?
>
>Jim MacDonald wrote:
>
>>I was= doing something jus=3D t like this last night... typically if you
are
>>running a command =3D say DF-k for example.
>> =
>
>
>
>---------
>To unsu= bscribe, send email to <aklug-request@aklug.org>
>with 'unsu= bscribe' in the message body.
>
>
Actually, th= e situation is more like this. I've got a file of data
(datain)= . I've created a simple program in C (foo) that takes data from
stdin, processes it, and spits the results to stdout. I want to be a= ble
from the shell to send the contents of datain to stdin of foo, an= d then
have the stdout of foo to be put into another file of data (da= taout).

This works fine for that purpose:
$ cat datain | fo= o | cat >dataout

But I was wondering if there was a shorter = way to do it, without the cat
program. I think that
$ foo = >dataout
will put stdout of foo into dataout, but
$ datain &g= t; add >dataout
doesn't seem to work, since I get error
$ bas= h: ./datain: Permission denied
I assume this is because my bad syntax = is trying to treat 'datain' like
a program. I imagine I will ev= entually find out how to do this
correctly when I am going thru tutor= ials, but was hoping someone might
give me a 'sneak peek' into the pr= oper syntax.

---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Fri Oct 31 17:47:47 2008

This archive was generated by hypermail 2.1.8 : Fri Oct 31 2008 - 17:47:47 AKDT