Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Favorites infavorites:mine
infavorites:1234
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with Search options user 61909

grep is a command-line tool for searching text patterns in files

1
vote
grep has a switch -A that tells it to print a number of lines after the match. In this case, just use -A 1 and you'll get ouptut like !!!!!!!!!!! 76567 -- !!!!!!!!!!! 87 -- !!!!!!!!!!! Now just grep out the numbers with | grep -e '[0-9]'. …
answered Mar 16 '14 by orion
21
votes
stream, or grep -i 'foo' $(cat files.txt) to give grep all the files. However, if there are too many files on the list, you may have problems with number of arguments. In that case I'd just write while read filename; do grep -Hi 'foo' "$filename"; done < files.txt …
answered Jan 13 '15 by orion
89
votes
less has very powerful pattern matching.  From the man page: &pattern Display only lines which match the pattern; lines which do not match the pattern are not displayed.  If pattern is empty …
answered Jan 15 '15 by orion
6
votes
Do everything with awk. Initialize counter, count and print (grep+count) with pattern matching and output count at the end: awk 'BEGIN { c=0} pattern{ c++; print $0 } END{ print 1000000/c }' You …
answered Mar 14 '14 by orion
1
vote
grep is the way to go, it returns 0 if a match is found. You don't actually need to output the line, so just discard the line and use the test. In your case, it would just be lastline=$(tail -n1 … logfile) if grep pattern <<<"$lastline" &>/dev/null; then echo "yay, found pattern" else echo "darn" fi Observe the "here string" construct <<< which presents the string as a file for grep to …
answered Jan 23 '15 by orion