adding a filename into a data file

Hugh Gallagher hugh at hcgallagher.co.uk
Mon Nov 5 07:05:47 PST 2012


Just for fun, I did it with some abuse of the default grep output and a bit
of sed.

grep '.' * | sed 's/^\([^.]*\)\.[a-z]*:/\1 /'


On 5 November 2012 14:37, Tony Edwardson <Tony.Edwardson at lchclearnet.com>wrote:

> or just
> while  (<>) {
>             print "$ARGV $_";
> }
>
> -----Original Message-----
> From: MiltonKeynes-pm [mailto:miltonkeynes-pm-bounces+tony.edwardson=
> lchclearnet.com at pm.org] On Behalf Of Benjamin Martin
> Sent: 05 November 2012 14:33
> To: miltonkeynes-pm at pm.org
> Subject: Re: adding a filename into a data file
>
> On 05/11/12 14:13, Matt Croft wrote:
> > Is this possible in perl?
>
> Something like this:
>
> #!/usr/bin/env perl
>
> use strict;
> use warnings;
> use autodie;
>
> my $base_dir = "/home/person";   # as base dir to read/write file to/from
> my @files = qw/file1.txt file2.txt/;  # the files to read and combine
>
> open $new_fh, ">", "$base_dir/NEWFILE.txt"; # open the master file to
> receive all files content
> foreach my $f (@files) {
>
>    my $fh
>    open $fh, "<", "$base_dir/$f";
>    while(<$fh>) {
>      print $new_fh "$f $_";
>    }
>    close $fh;
>
> }
> close $fh2;
>
>
> This email, its content and any files transmitted with it are intended
> solely for the addressee(s) and may be legally privileged and/or
> confidential. If you are not the intended recipient, you may not divulge
> any of its contents to anyone and should delete the email and contact the
> sender on the telephone number shown above or via return email. Messages
> sent via this medium may be subject to delays, non-delivery and
> unauthorised alteration.  This email has been prepared using information
> believed by the author to be reliable and accurate, but neither TwentyCi
> Limited, nor any of its subsidiaries or associates makes any warranty as to
> its accuracy or completeness.  Any opinions or recommendations expressed
> herein are solely those of the author. TwentyCi Limited is a company
> registered in England, No.06943607. The registered office address is: 6
> Whittle Court Knowlhill Milton Keynes MK5 8FT
> _______________________________________________
> MiltonKeynes-pm mailing list
> MiltonKeynes-pm at pm.org
> http://mail.pm.org/mailman/listinfo/miltonkeynes-pm
>
>
> A copy of the LCH.Clearnet e-mail disclaimer can be found at:
> www.lchclearnet.com/disclaimer/email
>
> LCH.Clearnet Limited, Registered Office: Aldgate House, 33 Aldgate High
> Street, London EC3N 1EA.
> Recognised as a Clearing House under the Financial Services & Markets Act
> 2000. Reg in England No.25932.
> LCH.Clearnet SA, Siège Social, 18 rue du Quatre Septembre, 75002 Paris,
> Chambre de Compensation conformément au Code Monétaire et Financier.
> _______________________________________________
> MiltonKeynes-pm mailing list
> MiltonKeynes-pm at pm.org
> http://mail.pm.org/mailman/listinfo/miltonkeynes-pm
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/miltonkeynes-pm/attachments/20121105/7d008047/attachment-0001.html>


More information about the MiltonKeynes-pm mailing list