Re: piping a groups of line to a program



tks a lot!!!

On May 30, 7:34 pm, "Chris F.A. Johnson" <cfajohn...@xxxxxxxxx> wrote:
On 2007-05-30, rhXX wrote:
hi all,

i want to send a group of lines to a program in a script shell.

now i'm using:

echo "line 1" > $TMPFILE
echo "line 2" >> $TMPFILE
...
echo "line N" >> $TMPFILE

cat $TMPFILE | prog

rm -f $TMPFILE

it seems me very primitive, create / delete a temp file only to
"group" the lines for piping

is it any method to pipe these line directly without temp file?

{
echo "line 1"
echo "line 2"
...
echo "line N"

} | prog

Or:

printf "%s\n" "line 1" \
"line 2" ... \
"line N" | prog

--
Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence


.



Relevant Pages

  • gcc3: C++ exceptions from shared libraries
    ... The shlib defines and throws an exception that is ... sample application (prog) to demonstrate the problem. ... $echo 'WARNING: not restoring timestamps. ... X CShLib obj; ...
    (comp.os.linux.development.apps)
  • trapping exit code from system()
    ... I'm calling a compiled program from gnuplot using: ... system 'prog --help; echo $?' ... but I'm not sure how to trap that value into a gnuplot variable to use ...
    (comp.graphics.apps.gnuplot)
  • Re: piping a group of "echo" to a program
    ... cat $TMPFILE | prog ... rm -f $TMPFILE ... but if you really need to group commands' output together into ... echo "line 1" ...
    (comp.unix.programmer)
  • Re: C++ recieve data from pipe
    ... argument or from a pipe (echo "xxx12zzz" | prog). ... How do i read the data from the pipe? ...
    (comp.os.linux.development.apps)
  • Re: piping a groups of line to a program
    ... i want to send a group of lines to a program in a script shell. ... cat $TMPFILE | prog ... rm -f $TMPFILE ... echo "line 1" ...
    (comp.os.linux.misc)