Sponsored Content
Top Forums Shell Programming and Scripting How to find union of two files Post 91957 by stevefox on Tuesday 6th of December 2005 09:25:38 PM
Old 12-06-2005
Thanks Livio
However your code did not give input1.txt minus the union of input1.txt and input2.txt which is 3.

I worked out that I can do this by the code below but is there a simpler way to do this using standard Unix commands? (possibly in one line?)

Code:
cat input1.txt input2.txt | sort | uniq -d > union
cat input1.txt union | sort | uniq -c > union2
sed -n '/1 /p' union2 > union3
sed -e 's/   1 //g' union3


Last edited by stevefox; 12-06-2005 at 10:46 PM..
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find files older than 20 days & not use find

I need to find files that have the ending of .out and that are older than 20 days. However, I cannot use find as I do not want to search in the directories that are underneath the directory that I am searching in. How can this be done?? Find returns files that I do not want. (2 Replies)
Discussion started by: halo98
2 Replies

2. Shell Programming and Scripting

Little bit weired : Find files in UNIX w/o using find or where command

Yes , I have to find a file in unix without using any find or where commands.Any pointers for the same would be very helpful as i am beginner in shell scritping and need a solution for the same. Thanks in advance. Regards Jatin Jain (10 Replies)
Discussion started by: jatin.jain
10 Replies

3. 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

4. Shell Programming and Scripting

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 Replies)
Discussion started by: tal
2 Replies

5. 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

6. 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

7. 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

8. 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

9. Shell Programming and Scripting

Find command to find a word from list of files

I need to find a word '% Retail by State' in the folder /usr/sas/reports/RetailSalesTaxallocation. When I tried like below, -bash-4.1$ cd /usr/sas/reports/RetailSalesTaxallocation -bash-4.1$ find ./ -name % Retail by State find: paths must precede expression: Retail Usage: find ... (10 Replies)
Discussion started by: Ram Kumar_BE
10 Replies
IXPC(1) 						      General Commands Manual							   IXPC(1)

NAME
ixpc - ixp client SYNOPSIS
ixpc [-a address] action file ixpc -v DESCRIPTION
Overview ixpc is a client to access a 9P file server from the command line or from shell scripts. It can be used to configure wmii(1). Options -a address Lets you specify the address to which ixpc will establish a connection. If this option is not supplied, and the environment variable IXP_ADDRESS is set, ixpc will use this value as its address. Currently, the address can only be a unix socket file or a tcp socket. The syntax for address is taken (along with many other profound ideas) from the Plan 9 operating system and has the form unix!/path/to/socket for unix socket files, and tcp!hostname!port for tcp sockets. -v Prints version information to stdout, then exits. The syntax of the actions is as follows: write Writes the supplied data from the standard input to file, overwriting any previous data. The data to be written is arbitrary and only gains meaning (and restrictions) when it is interpreted by wmiiwm(1). See EXAMPLES below. xwrite The same as write, but the data is taken from subsequent arguments, rather than the standard input. create Creates file or directory. If the file exists, nothing is done. ls Lists files and directories. read Reads file or directory contents. remove Removes file or directory tree. ENVIRONMENT
IXP_ADDRESS See above. EXAMPLES
ixpc ls / This prints the root directory of the wmii filesystem, if IXP_ADDRESS is set to the address of wmii. For more information about the contents of this filesystem, see wmiiwm(1). ixpc xwrite /ctl quit Write 'quit' to the main control file of the wmii filesystem, effectively leaving wmii. ixpc write /keys < keys.txt Replace the contents of /keys with the contents of keys.txt SEE ALSO
wmii(1) http://www.cs.bell-labs.com/sys/man/5/INDEX.html ixpc-VERSION IXPC(1)
All times are GMT -4. The time now is 02:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy