summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLevi Bostian <levi.bostian@gmail.com>2014-10-17 19:56:07 -0500
committerLevi Bostian <levi.bostian@gmail.com>2014-10-17 19:56:07 -0500
commit7cfa4a7d5d72c9559ff3dfa142741fa3cf293e90 (patch)
treecbc67609d582f7177f76bff631880f2bfc517b3f
parentbc6a21835f862a4c8b386fce48aebd2cdd1a5232 (diff)
parentd83a0f038558cf32680287417bbd692b33fe13cc (diff)
Merge pull request #789 from gskielian/master
Added `sed ` and `grep` examples/descriptions to useful-commands
-rw-r--r--bash.html.markdown9
1 files changed, 9 insertions, 0 deletions
diff --git a/bash.html.markdown b/bash.html.markdown
index dc7d32b6..9b199b8c 100644
--- a/bash.html.markdown
+++ b/bash.html.markdown
@@ -9,6 +9,7 @@ contributors:
- ["akirahirose", "https://twitter.com/akirahirose"]
- ["Anton Strömkvist", "http://lutic.org/"]
- ["Rahil Momin", "https://github.com/iamrahil"]
+ - ["Gregrory Kielian", "https://github.com/gskielian"]
filename: LearnBash.sh
---
@@ -199,4 +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 '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
```