Copy(append ) the contents of file1 and file2 to file3


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Copy(append ) the contents of file1 and file2 to file3
# 8  
Old 12-11-2014
In a recent bash, you could also try
Code:
export LOG1=myLogfile1.log
export LOG2=myLogfile2.log
export LOG3=myLogfile3.log
cat $LOG{1..3}

These 2 Users Gave Thanks to RudiC For This Post:
# 9  
Old 12-11-2014
Quote:
Originally Posted by RudiC
In a recent bash, you could also try
Code:
export LOG1=myLogfile1.log
export LOG2=myLogfile2.log
export LOG3=myLogfile3.log
cat $LOG{1..3}

RudiC, Sir you are too good. Thank you for nice code. Smilie

Thanks,
R. Singh
# 10  
Old 12-15-2014
I am surprised no one has pointed this out, but you might already know it:

1 - combine several log files into one file when it happens:
Code:
tail -f filename filename2 filename3 > logfile

This will take any input that comes into filename or the other two files and instantly place this in logfile.
This means that the logfile will contain the rows from the different input files sequentially. I.e:
Code:
output from a simulated logfile:
row from filename
row from filename
row from filename3
row from filename2
row from filename3
row from filename

which might not be what you want to achieve, but it works.

2 - > and >> are two different redirect operators in Unix.
> will create and overwrite a file while >> will create or append to a file.
I.e:
Code:
[~/Temp]$ cat file1
Scooby
[~/Temp]$ cat file2
Doo
[~/Temp]$ cat file1 > file3
[~/Temp]$ cat file2 > file3
[~/Temp]$ cat file3
Doo
[~/Temp]$ cat file1 > file3
[~/Temp]$ cat file2 >> file3
[~/Temp]$ cat file3
Scooby
Doo
[~/Temp]$

Hope this brings some value to your problem solving.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

PYTHON COPY Contents of file1 into a specific entry in file2

file1 cat dog fish file2 This is a bunch of lines <!-- INSERT ANIMALS HERE --> horse cheetah post results file2 This is a bunch of lines <!-- INSERT ANIMALS HERE --> cat dog fish horse (1 Reply)
Discussion started by: TY718
1 Replies

2. Shell Programming and Scripting

awk or any other means to find IP (File1 / MAC (File2)) entries and putting them on File3

Hi everyone, I would like to complete the following could you please find some time and help me to achieve below: File 1 has a list of IP address (more than 1k) File1:1.1.1.1 2.2.2.2 1.1.1.2 3.3.3.3 2.3.3.2File 2 has content like this:Internet 11.165.91.244 0 Incomplete ... (4 Replies)
Discussion started by: redred
4 Replies

3. Shell Programming and Scripting

How to append two files(file1 and file2) Please help me?

Hi I have two files file1 and file2 File1 10,000 entries:It has 3 columns below. conn=232257 client=xxx.xxx.xx.xxx:60491 protocol=LDAP File2 has 500 entries It has two columns. conn=232257 dn="uid=xxxx,ou=xxxx,ou=xxxx,dc=xxxxx,dc=xxxx" conn=232398... (10 Replies)
Discussion started by: buzzme
10 Replies

4. Shell Programming and Scripting

awk read in file1, gsub in file2, print to file3

I'm trying to use awk to do the following. I have file1 with many lines, each containing 5 fields describing an individual set. I have file2 which is a template config file with variable space holders to be replaced by the values in file1. I would like to substitute each set of values in file1 with... (6 Replies)
Discussion started by: msmehaffey
6 Replies

5. Shell Programming and Scripting

Performance issue with fgrep -vf file1 file2>file3

Hi all, My requirement is that i have two files file1 and file2. file1 content is present in file2. i want to have a final which will have file2 contents but not the contents of file1 so I am running below command. fgrep -vf file1 file2>file3 no of records in file1 is 65282 no of records... (10 Replies)
Discussion started by: Lakshman_Gupta
10 Replies

6. UNIX for Dummies Questions & Answers

if matching strings in file1 and file2, add column from file1 to file2

I have very limited coding skills but I'm wondering if someone could help me with this. There are many threads about matching strings in two files, but I have no idea how to add a column from one file to another based on a matching string. I'm looking to match column1 in file1 to the number... (3 Replies)
Discussion started by: pathunkathunk
3 Replies

7. Shell Programming and Scripting

append text from file1 to the end of each line in file2

hi; my file2.txt:portname=1;list=10.11;l- portname=2;list=10.12;l- portname=3;list=10.13;l- ... my file1.txt:;"{'sector=%27'}"\&> so; i want to see:portname=1;list=10.11;l-;"{'sector=%27'}"\&> portname=2;list=10.12;l-;"{'sector=%27'}"\&> portname=3;list=10.13;l-;"{'sector=%27'}"\&>... (4 Replies)
Discussion started by: gc_sw
4 Replies

8. UNIX for Dummies Questions & Answers

cat file1 file2 > file3

file1 has pgap500 500 file2 has bunch of data cat file1 file2 > file3 cp file2 file3.dat then vi pgap500 500 onto 1st line compare file3 and fil3.dat, they are not the same. any idea ? the 1st line, i want to put pg500 xxx ---------- Post updated at 07:35 AM ---------- Previous... (2 Replies)
Discussion started by: tjmannonline
2 Replies

9. UNIX for Advanced & Expert Users

print contents of file2 for matching pattern in file1 - AWK

File1 row is same as column 2 in file 2. Also file 2 will either start with A, B or C. And 3rd column in file 2 is always F2. When column 2 of file 2 matches file1 column, print all those rows into a separate file. Here is an example. file 1: 100 103 104 108 file 2: ... (6 Replies)
Discussion started by: i.scientist
6 Replies

10. UNIX for Dummies Questions & Answers

echo "ABC" > file1.txt file2.txt file3.txt

Hi Guru's, I need to create 3 files with the contents "ABC" using single command. Iam using: echo "ABC" > file1.txt file2.txt file3.txt the above command is not working. pls help me... With Regards / Ganapati (4 Replies)
Discussion started by: ganapati
4 Replies
Login or Register to Ask a Question