bash - How to grep -o without the -o -


i've got busybox v1.01 providing commands. hence, -o not included in grep. how can grep -o behavior without ... -o?

if have sed can use simple regex. (see linuxquestions.org)

sed -n 's/.*\(pattern\).*/\1/p' file 

so find text stackoverflow in file file.txt you'd write

sed -n 's/.*\(stackoverflow\).*/\1/p' file.txt 

remember pattern in sed command regular expression. if pattern contains meta characters of regular expression, need escaped.


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -