Find the answer to your Linux question:
Results 1 to 2 of 2
I'm trying to combine several statements and am having trouble. I've been away from the Linux world for a while, so I'm a little rusty. Here's the deal: I have ...
  1. #1
    Just Joined!
    Join Date
    Sep 2007
    Posts
    1

    Help with pipes

    I'm trying to combine several statements and am having trouble. I've been away from the Linux world for a while, so I'm a little rusty. Here's the deal:

    I have a script that is called like:
    Code:
    scriptname inputfile1 inputfile2
    Normally, that script is called and the output sent to a temporary file or to the printer like:
    Code:
    scriptname inputfile1 inputfile2 > tempfile
    or
    Code:
    scriptname inputfile1 inputfile2 | lp -d queuename
    What I want to do is prepend some text to the output of the script so that what gets sent to the file/printer will look like:
    Code:
    mytextscriptoutput
    The catch is that I want to do this a) with a single command line statement and b) without any temporary files or extra scripts. Is this possible?

    Thanks!

  2. #2
    Linux Enthusiast likwid's Avatar
    Join Date
    Dec 2006
    Location
    MA
    Posts
    649
    Yea, I have to do this when users need a large amount of documents printed with the filename at the top. I do something like this

    Code:
    for filename in *; do 
      (echo $filename ; cat $filename) | lpr -P printer
    done
    So you want to do i think would be a little different, like:

    Code:
    (echo SOMETHING ; scriptname inputfile1 inputfile2) | lpr -P printer

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...