{"id":186,"date":"2009-10-29T01:52:25","date_gmt":"2009-10-28T23:52:25","guid":{"rendered":"http:\/\/www.shukko.com\/x3\/2009\/10\/29\/grep-ii-x4-620-d\/"},"modified":"2009-10-29T01:55:26","modified_gmt":"2009-10-28T23:55:26","slug":"grep-ii-x4-620-d","status":"publish","type":"post","link":"https:\/\/www.shukko.com\/x3\/2009\/10\/29\/grep-ii-x4-620-d\/","title":{"rendered":"GREP II X4 620 :D"},"content":{"rendered":"<p>GREP IS MY FRIEND AND I LOVE IT!<\/p>\n<p>.\/t.pl calistirmis serefiz! Proftpd loglarinda bulucam!<br \/>\n<code>grep -wr 't\\.pl' \/var\/log\/proftpd\/<\/code><\/p>\n<p>Geri kalan grep helpi \ud83d\ude42<br \/>\n<code><br \/>\n[root@avokado ~]# grep --help<br \/>\nUsage: grep [OPTION]... PATTERN [FILE] ...<br \/>\nSearch for PATTERN in each FILE or standard input.<br \/>\nExample: grep -i 'hello world' menu.h main.c<\/p>\n<p>Regexp selection and interpretation:<br \/>\n  -E, --extended-regexp     PATTERN is an extended regular expression<br \/>\n  -F, --fixed-strings       PATTERN is a set of newline-separated strings<br \/>\n  -G, --basic-regexp        PATTERN is a basic regular expression<br \/>\n  -P, --perl-regexp         PATTERN is a Perl regular expression<br \/>\n  -e, --regexp=PATTERN      use PATTERN as a regular expression<br \/>\n  -f, --file=FILE           obtain PATTERN from FILE<br \/>\n  -i, --ignore-case         ignore case distinctions<br \/>\n  -w, --word-regexp         force PATTERN to match only whole words<br \/>\n  -x, --line-regexp         force PATTERN to match only whole lines<br \/>\n  -z, --null-data           a data line ends in 0 byte, not newline<\/p>\n<p>Miscellaneous:<br \/>\n  -s, --no-messages         suppress error messages<br \/>\n  -v, --invert-match        select non-matching lines<br \/>\n  -V, --version             print version information and exit<br \/>\n      --help                display this help and exit<br \/>\n      --mmap                use memory-mapped input if possible<\/p>\n<p>Output control:<br \/>\n  -m, --max-count=NUM       stop after NUM matches<br \/>\n  -b, --byte-offset         print the byte offset with output lines<br \/>\n  -n, --line-number         print line number with output lines<br \/>\n      --line-buffered       flush output on every line<br \/>\n  -H, --with-filename       print the filename for each match<br \/>\n  -h, --no-filename         suppress the prefixing filename on output<br \/>\n      --label=LABEL         print LABEL as filename for standard input<br \/>\n  -o, --only-matching       show only the part of a line matching PATTERN<br \/>\n  -q, --quiet, --silent     suppress all normal output<br \/>\n      --binary-files=TYPE   assume that binary files are TYPE<br \/>\n                            TYPE is 'binary', 'text', or 'without-match'<br \/>\n  -a, --text                equivalent to --binary-files=text<br \/>\n  -I                        equivalent to --binary-files=without-match<br \/>\n  -d, --directories=ACTION  how to handle directories<br \/>\n                            ACTION is 'read', 'recurse', or 'skip'<br \/>\n  -D, --devices=ACTION      how to handle devices, FIFOs and sockets<br \/>\n                            ACTION is 'read' or 'skip'<br \/>\n  -R, -r, --recursive       equivalent to --directories=recurse<br \/>\n      --include=PATTERN     files that match PATTERN will be examined<br \/>\n      --exclude=PATTERN     files that match PATTERN will be skipped.<br \/>\n      --exclude-from=FILE   files that match PATTERN in FILE will be skipped.<br \/>\n  -L, --files-without-match only print FILE names containing no match<br \/>\n  -l, --files-with-matches  only print FILE names containing matches<br \/>\n  -c, --count               only print a count of matching lines per FILE<br \/>\n  -Z, --null                print 0 byte after FILE name<\/p>\n<p>Context control:<br \/>\n  -B, --before-context=NUM  print NUM lines of leading context<br \/>\n  -A, --after-context=NUM   print NUM lines of trailing context<br \/>\n  -C, --context=NUM         print NUM lines of output context<br \/>\n  -NUM                      same as --context=NUM<br \/>\n      --color[=WHEN],<br \/>\n      --colour[=WHEN]       use markers to distinguish the matching string<br \/>\n                            WHEN may be `always', `never' or `auto'.<br \/>\n  -U, --binary              do not strip CR characters at EOL (MSDOS)<br \/>\n  -u, --unix-byte-offsets   report offsets as if CRs were not there (MSDOS)<\/p>\n<p>`egrep' means `grep -E'.  `fgrep' means `grep -F'.<br \/>\nWith no FILE, or when FILE is -, read standard input.  If less than<br \/>\ntwo FILEs given, assume -h.  Exit status is 0 if match, 1 if no match,<br \/>\nand 2 if trouble.<\/p>\n<p>Report bugs to <bug-grep@gnu.org>.<\/p>\n<p><\/code><\/p>\n<p>BUNUDA ALEX YAZMIS &#8211; SAGOLSUN.. (alexde kimse? :))<\/p>\n<p><code><br \/>\nHi, Lucy.  Lucy's question was:<br \/>\n There's probably a very simple answer to this question,<br \/>\n but I cannot for the life of me figure it out.<br \/>\n How do you grep for an EXACT match of a string?<br \/>\n[data (abbreviated) was:]<br \/>\n 10.1.     #Bridgewater<br \/>\n 10.10.  #Scranton<br \/>\n[etc...]<br \/>\n I'm trying to grep for the exact match of 10.1. in a script.<br \/>\n That string will actually be in a variable defined previously<br \/>\n in the script. When the grep runs, it outputs every line containing<br \/>\n 10.1?.  How do I prevent that from happening?<br \/>\n - - -<br \/>\nAnswer:<\/p>\n<p>grep actually stands for Global Regular Expression Print, where the<br \/>\nReg'Exp' is a description of the string to match.<br \/>\n(From the editor ed(1), use: g\/regexp\/p (to view lines with \"foo\"))<br \/>\nThe extra things that need to be addressed in the regexp are:<br \/>\n1) You need to match the beginning of line<br \/>\n2) You want to see whitespace immediately after the \"10.1.\"<br \/>\n3) You don't want to use simply \".\" for periods,<br \/>\n   because a period in a regexp really means \"match any single character\".<\/p>\n<p>You need:  grep '^10\\.1\\.[    ]'<\/p>\n<p>...where the gap between the square brackets [] is made up of one space<br \/>\nand one tab in either order.  The carat \"^\" matches the beginning of line.<br \/>\nThe backslash \"\\\" tells grep that the following period only is to match<br \/>\nperiods.<\/p>\n<p>The backslashes can cause difficulties in shell scripts, you may prefer:<\/p>\n<p>     '^10[.]1[.][   ]'<\/p>\n<p>Square-bracketed bits match one character position of the input,<br \/>\nwhere the matched character must be one of the ones between the<br \/>\nbrackets.  Very few characters are still special (or \"weird\" if<br \/>\nyou prefer) between brackets, just ^, -, and ].<\/p>\n<p>You should use single quotes in the shell, since double quotes<br \/>\nstill allow various substitutions on the quoted text, include<br \/>\noutput-, variable-, and history-substitution.<\/p>\n<p>When using $ to access the value of a shell variable, where the<br \/>\nexact composition of the whitespace in that variable matter,<br \/>\nenclose the $variable substitution in double quotes.  This keeps<br \/>\nwhitespacing literally, instead of interpreting them as<br \/>\ncommand-argument splitters.<\/p>\n<p>So in the end, you might have:<\/p>\n<p>     regexp='^10[.]1[.][      ]'  # last [] contains space and tab<br \/>\n     grep \"$regexp\" filename<\/p>\n<p>Other notes:  use a dollar sign to match end-of-line.  Example, to<br \/>\nmatch a line containing the word \"foo\" and ABSOLUTELY NOTHING ELSE, use:<\/p>\n<p>     grep '^foo$'<\/p>\n<p>-Alex.<\/p>\n<p><\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>GREP IS MY FRIEND AND I LOVE IT! .\/t.pl calistirmis serefiz! Proftpd loglarinda bulucam! grep -wr &#8216;t\\.pl&#8217; \/var\/log\/proftpd\/ Geri kalan grep helpi \ud83d\ude42 [root@avokado ~]# grep &#8211;help Usage: grep [OPTION]&#8230; PATTERN [FILE] &#8230; Search for PATTERN in each FILE or standard input. Example: grep -i &#8216;hello world&#8217; menu.h main.c Regexp selection and interpretation: -E, &#8211;extended-regexp [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-186","post","type-post","status-publish","format-standard","hentry","category-kategerisiz"],"_links":{"self":[{"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/posts\/186","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/comments?post=186"}],"version-history":[{"count":2,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/posts\/186\/revisions"}],"predecessor-version":[{"id":187,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/posts\/186\/revisions\/187"}],"wp:attachment":[{"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/media?parent=186"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/categories?post=186"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/tags?post=186"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}