Text files union


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Text files union
# 1  
Old 03-11-2009
Text files union

How can i union two files that each of them contain text to one new file in unix shell scripting or in awk scripting language?
# 2  
Old 03-11-2009
look here.
# 3  
Old 03-11-2009
What do you mean by "union"? Do you just want the contents of both files together in one file? If so, just use cat.

Code:
cat file1 file2 > file3

Do you want a file containing only the lines that are the same in both? Use fgrep.

Code:
fgrep file1 file2 > file3

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Programming

Event driven programming / epoll / typedef union / session data array

Sorry for the “word salad” subject, but I wanted to cast a wide net for help. I've created an IP (Internet Protocol) server which serves HTTP, SMTP, and FTP requests. As you probably know, they all require creating a socket, listening on it, accepting connections, and then having a short... (3 Replies)
Discussion started by: John S.
3 Replies

2. Shell Programming and Scripting

Read text between regexps and write into files based on a field in the text

Hi, I have a huge file that has data something like shown below: huge_file.txt start regexp Name=Name1 Title=Analyst Address=Address1 Department=Finance end regexp some text some text start regexp Name=Name2 Title=Controller Address=Address2 Department=Finance end regexp (7 Replies)
Discussion started by: r3d3
7 Replies

3. Shell Programming and Scripting

Script to create a text file whose content is the text of another files

Hello everyone, I work under Ubuntu 11.10 (c-shell) I need a script to create a new text file whose content is the text of another text files that are in the directory $DIRMAIL at this moment. I will show you an example: - On the one hand, there is a directory $DIRMAIL where there are... (1 Reply)
Discussion started by: tenteyu
1 Replies

4. Programming

GDB and GCC union

My concept may sound a bit cryptic but I what some startup information as to how we can use GDB APIs / debugging techniques in programs with GCC when we compile the program. We can definitely tell gcc to link GDB libs also. The ultimate aid would be that when the compiled programs executes it... (4 Replies)
Discussion started by: uunniixx
4 Replies

5. Web Development

Intersection and union of array by hash

Hi, A piece of script from Perl-cookbook I do not understand, and post here for explanation. The purpose is to find the element in either array (union), and in both array (intersection). Thank you in advance. @a=qw(1 3 5 6 7 8); @b=qw(2 3 5 7 9); foreach $e (@a, @b) {$union{$e}++ &&... (3 Replies)
Discussion started by: yifangt
3 Replies

6. Shell Programming and Scripting

awk: union regions

Hi all, I have difficulty to solve the followign problem. mydata: StartPoint EndPoint 22 55 2222 2230 33 66 44 58 222 240 11 25 22 60 33 45 The union of above... (2 Replies)
Discussion started by: phoeberunner
2 Replies

7. Shell Programming and Scripting

union of two files

Given two files of the same format (For example number1|text1|number2) what is the command to print lines in file1 which do not occur in file2? diff command seems a bit complicated for me for this purpose. Please help!! Thank you very much. (3 Replies)
Discussion started by: sherkaner
3 Replies

8. Shell Programming and Scripting

How to find union of two files

Is there a command in unix to find the union of two files and removing the union from one of the files? e.g. I have two files input1.txt and input2.txt with the contents below: $ more input1.txt 4 2 3 2 $ more input2.txt 5 4 4 8 2 I want to find the union of the two and... (7 Replies)
Discussion started by: stevefox
7 Replies

9. UNIX for Dummies Questions & Answers

grep multiple text files in folder into 1 text file?

How do I use the grep command to take mutiple text files in a folder and make one huge text file out of them. I'm using Mac OS X and can not find a text tool that does it so I figured I'd resort to the BSD Unix CLI for a solution... there are 5,300 files that I want to write to one huge file so... (7 Replies)
Discussion started by: coppertone
7 Replies
Login or Register to Ask a Question