-   Programming (
-   -   Basic piping issue (

belorion 12-15-2004 10:02 AM

Basic piping issue
I have a program, foo.exe, that takes a file name as input:

$> ./foo.exe myfile.txt

I need to replace the first line of this file using sed, but I don't want to write it out this new file since it is about 1gig in size (and I can't just go in to edit the original, I don't have permission).

So I thought, why not just pipe it?

However, I haven't gotten it to work yet. This is what I tried:

$>sed -e '1s/old/new/' myfile.txt | foo.exe -o myoutput

My program, foo.exe, gives me the "help" showing usage because it isn't seeing my input file. What am I doing wrong?

320mb 12-15-2004 10:12 AM

do you have read permission to foo.exe ??

if not then your script won't work.......!!

belorion 12-15-2004 10:14 AM

I have full permissions on foo.exe, I only have read permission on the input file. But I need to change the first line of this input file, which is 1gig+ (so I don't want to have to write it out.)

AnanthaP 12-16-2004 07:07 PM

first of all, Foo.exe looks like a specific program that takes one argument as the input file. Obviously, it doesn't accept nil arguments and default to stdin. Also the argument expected may be thge name of an existing file and then you might have no option but to write it to a file first.

Please try
foo.exe `sed -e '1s/old/new/' myfile.txt`

The sed should get evaluated first and then the result passed to foo.exe.

If it still doesn't work, then you have to write it to a file or else get the programmer to provide for reading from srtdin if argv(1) = "-" - say.


All times are GMT -5. The time now is 01:37 AM.