File 1:happysadcalmpalmFile 2:palmdreamcalmI want to compare the two files and display only those line that are common in both the files, but I want to maintain the order of File 2. My output should be:palmcalmI know I can use comm after sorting the files but I want to maintain the order. Is there any way to do this?
Compare two files line by line without comm (I need to maintain order of file 1)
text processing;text;file comparison;comm
Use grep:$ grep -Ff f1 f2palmcalmman grep:   -F, --fixed-strings          Interpret PATTERN as a list of fixed strings (instead of regular          expressions), separated by newlines,  any  of  which  is  to  be          matched.   -f FILE, --file=FILE          Obtain patterns from FILE, one per line.  If this option is used          multiple times or is combined with  the  -e  (--regexp)  option,          search  for  all  patterns  given.  The empty file contains zero          patterns, and therefore matches nothing.