summaryrefslogtreecommitdiffhomepage
path: root/bash.html.markdown
diff options
context:
space:
mode:
authorGregory S. Kielian <gregory.kielian@gmail.com>2014-10-04 14:50:00 -0700
committerGregory S. Kielian <gregory.kielian@gmail.com>2014-10-04 14:50:00 -0700
commitd83a0f038558cf32680287417bbd692b33fe13cc (patch)
tree3bb2d87b05a6706d8e1f9de4e4281ca998cb83ef /bash.html.markdown
parentd22d591e3e2120dd1bed70cd8093569c8b7101c2 (diff)
Changed descriptions, added grep, fgrep examples
Diffstat (limited to 'bash.html.markdown')
-rw-r--r--bash.html.markdown12
1 files changed, 8 insertions, 4 deletions
diff --git a/bash.html.markdown b/bash.html.markdown
index 160fe8f2..9b199b8c 100644
--- a/bash.html.markdown
+++ b/bash.html.markdown
@@ -200,8 +200,12 @@ sort file.txt
uniq -d file.txt
# prints only the first column before the ',' character
cut -d ',' -f 1 file.txt
-# replaces every occurrence of 'apples' with 'oranges' in file.txt
-sed -i 's/apples/oranges/g' file.txt
-# prints the number of lines containing the string "foo" in file.txt
-grep -c "foo" file.txt
+# replaces every occurrence of 'okay' with 'great' in file.txt, (regex compatible)
+sed -i 's/okay/great/g' file.txt
+# print to stdout all lines of file.txt which match some regex, the example prints lines which beginning with "foo" and end in "bar"
+grep "^foo.*bar$" file.txt
+# pass the option "-c" to instead print the number of lines matching the regex
+grep -c "^foo.*bar$" file.txt
+# if you literally want to search for the string, and not the regex, use fgrep (or grep -F)
+fgrep "^foo.*bar$" file.txt
```