If the files are sorted (they are in your example):
comm -23 file1 file2
-23
suppresses the lines that are in both files, or only in file 2. If the files are not sorted, pipe them through sort
first…
See the man page here
More Related Contents:
- Using grep and sed to find and replace a string
- How to ‘grep’ a continuous stream?
- Environment variable substitution in sed
- Better way to rename files based on multiple patterns
- How can I delete a newline if it is the last character in a file?
- Given two directory trees, how can I find out which files differ by content? [closed]
- Finding contents of one file in another file
- How to use sed to remove the last n lines of a file
- How to search and replace using grep
- How do I remove newlines from a text file?
- Insert multiple lines into a file after specified pattern using shell script
- How to check if sed has changed a file
- Replacing Control Character in sed
- Extract lines between two patterns from a file [duplicate]
- How to use sed to extract substring
- Replace whitespace with a comma in a text file in Linux
- Linux shell script to add leading zeros to file names
- create a file with prefix =file1 followed by the random number
- Linux grep command with relevant values as output
- Why to code a script which will check if some package is installed in linux and if not then install it?
- How to pass command output as multiple arguments to another command
- How to run a shell script when a file or directory changes?
- How can I use grep to show just filenames on Linux? [closed]
- Return value of sed for no match
- Add a bash script to path
- Docker Alpine executable binary not found even if in PATH
- Bash script execution with and without shebang in Linux and BSD
- How to compare two DateTime strings and return difference in hours? (bash shell)
- How to set process group of a shell script
- How to grep for case insensitive string in a file?