How to apend 1 file to another?

W

Wow

Do I have to read file1 and do a >> to file2? Any easiler way? Perl or Shell
scripts are both OK.
 
U

Uri Guttman

W" == Wow said:
Do I have to read file1 and do a >> to file2? Any easiler way? Perl
or Shell scripts are both OK.

use File::Slurp ;

my $text = read_file( 'file1' ) ;
append_file( 'file2', $text ) ;

uri
 
U

Uri Guttman

PI" == Public Interest said:
is there a way to apend it without read it first? such as cat a.txt b.txt >
b.txt

don't top post. read the group guidelines (posted regularly)

what do you think cat is doing there, twiddling its thumbs? it is
reading the file. and that shell example has a classic bug in it.

and even if you fixed the bug, it reads the second file which is not
needed.

file systems don't usually provide ways of moving data without reading
them. so how would you do it without reading the file?

and you asked for a perl solution and i gave you one. what more do you want?

uri
 
S

Sara

Uri Guttman said:
don't top post. read the group guidelines (posted regularly)

what do you think cat is doing there, twiddling its thumbs? it is
reading the file. and that shell example has a classic bug in it.

and even if you fixed the bug, it reads the second file which is not
needed.

file systems don't usually provide ways of moving data without reading
them. so how would you do it without reading the file?

and you asked for a perl solution and i gave you one. what more do you want?

uri

Uri you're not very Jolly for Christmastime :~

Just kidding have a nice holiday!!

G
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,248
Latest member
MagdalenaB

Latest Threads

Top