concating files together

Andrew Wilson andrew at rivendale.net
Fri May 23 09:13:17 CDT 2003


Hi Bernie

On Fri, May 23, 2003 at 02:46:27PM +0100, Boyle Bernadette wrote:
> Can anyone tell me id there is a Perl command to concat files into one. 
>  
> more /var/log/maillog* > /tmp/output

You can do that with perl, but you've already figured out how to do it
in the shell.  Was there something else you wanted to do, or can you not
use the shell?

I think that the quickest, easiest way to do it is to use command line
arguments to perl. The -p arguement iterates over each line of the files
named on the command line applys the perl script to each in turn and
then writes it to standard out. It opens each file in turn adn closes it
again so you don't have to woryy about that. If you do this and give it
an empty script, then it passes the lines through unaltered and
effectively ends up being a cat operation, thus:

  perl -p -e'' /var/log/maillog* > /tmp/output

I don't see that that's gaining you much over the shell version using
more though. Is there something more that you're trying to achieve?

andrew
--
Virgo: (Aug. 23 - Sept. 22) The older you get, the more you're convinced
that we were all put in this retirement home for a reason.



More information about the Belfast-pm mailing list