Cool commands to find / extract info from files
- Get the content from SEQUENCEA to SEQUENCEB in a file\\ Example, a file can contain multiple occurrence of resource {
Name = XXXXXX
Run = XXXXX
} Here SEQUENCEA is 'resource {' and SEQUENCEB is '}' \\ You need to do: sed -n -e '/SEQUENCEA/,/SEQUENCEB/ p' File Example: sed -n -e '/resource {/,/}/ p' resource.conf will display: Schedule {
Name = AAAAA
Run = AAAAA
}
Schedule {
Name = BBBBB
Run = BBBBB
}
[…]
- Grep with OR operator grep 'pattern1\|pattern2' filetogrep you can include regexp\\ References:
* http://www.thegeekstuff.com/2011/10/grep-or-and-not-operators/
* http://www.cyberciti.biz/faq/grep-regular-expressions/
- Next