On Tue, Jan 31, 2012 at 01:34:44PM -0600, Matt wrote:
> Perhaps asking wrong place but I have two directories both full of
> hundreds of text files.
> 
> dir1/file1
> dir1/file2
> dir2/file1
> dir2/file2
> 
> I want to append all files together with same name into a new directory.
> 
> dir1/file1 contains:
> hi
> by
> later
> 
> dir2/file1 contains:
> woops
> dropped
> 
> new_dir/file1 would contain:
> hi
> by
> later
> woops
> dropped
> 
> Any quick perl/bash/linux way to do that?  Perl myprogram v1 used two
> instances and directories for logs.  Perl myprogram v2 consolidates
> into one directory is the reason for merge.

This is zsh.  I presume it could be converted into bash fairly easily.
Run it from new_dir.

for f (../dir*/*) { cat $f >>| $f(:t) }

:t is essentially basename.

-- 
Paul Johnson - p...@pjcj.net
http://www.pjcj.net

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to