Intersection of two lists in Bash
        Posted  
        
            by User1
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by User1
        
        
        
        Published on 2010-04-23T03:37:14Z
        Indexed on 
            2010/04/23
            3:43 UTC
        
        
        Read the original article
        Hit count: 290
        
bash
I'm trying to write a simple script that will list the contents found in two lists. To simplify, let's use ls as an example. Imagine "one" and "two" are directories.
one=`ls one` two=`ls two` intersection $one $two
I'm still quite green in bash, so feel free to correct how I am doing this. I just need some command that will print out all files in "one" and "two". They must exist in both. You might call this the "intersection" between "one" and "two".
© Stack Overflow or respective owner