mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-05-06 14:58:31 +00:00
Merge pull request #789 from gskielian/master
Added `sed ` and `grep` examples/descriptions to useful-commands
This commit is contained in:
commit
7cfa4a7d5d
@ -9,6 +9,7 @@ contributors:
|
|||||||
- ["akirahirose", "https://twitter.com/akirahirose"]
|
- ["akirahirose", "https://twitter.com/akirahirose"]
|
||||||
- ["Anton Strömkvist", "http://lutic.org/"]
|
- ["Anton Strömkvist", "http://lutic.org/"]
|
||||||
- ["Rahil Momin", "https://github.com/iamrahil"]
|
- ["Rahil Momin", "https://github.com/iamrahil"]
|
||||||
|
- ["Gregrory Kielian", "https://github.com/gskielian"]
|
||||||
filename: LearnBash.sh
|
filename: LearnBash.sh
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -199,4 +200,12 @@ sort file.txt
|
|||||||
uniq -d file.txt
|
uniq -d file.txt
|
||||||
# prints only the first column before the ',' character
|
# prints only the first column before the ',' character
|
||||||
cut -d ',' -f 1 file.txt
|
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
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user