Comparing Files and Searching Files Flashcards
diff
compare 2 files for the difference between them
diff filename filename
sdiff
side by side comparison
vimdiff
highlights the differences in vim
grep
used to search for a pattern in a file
eg: grep dog myText.txt
grep -i
performs a search ignoring case
grep -c
counts the number of times the pattern occurs in the file
grep -n
proceed output with line number
grep -v
invert match. print lines that don’t match the pattern
file
tells you what’s in a file
|
Takes the standard output from one command and passes it in as standard input to the next command
command 1 | command 2
cut
used to cut a piece of a file out
cut -f N
specify which line number to display
cut -d delimeter
used to cut with a delimeter
grep bob /etc/password | cut -d: -ft,5 | sort | tr “:” “ “ | column -t
search for bob in the file password, then cut out only the first and 5 sections of the file separated by colons, then sort them alphabetically, then remove the colon and replace with whitespace, then format as a table