Linux Bash – sed substring
February 13th, 2009
No comments
CODE:
-
echo "This is the TEST(Message(with some tricky word)) from which i want to search." | <acronym title="Stream Editor">sed</acronym> 's/.*\(TEST.*))\).*$/\1/'
CODE:
-
echo `expr match "abba (album)" '.*(\(.*\)).*'` -> album
CODE:
-
stringZ=abcABC123ABCabc
-
# =======
-
-
echo `expr match "$stringZ" '\(.[b-c]*[A-Z]..[0-9]\)'` # abcABC1
-
echo `expr "$stringZ" : '\(.[b-c]*[A-Z]..[0-9]\)'` # abcABC1
-
echo `expr "$stringZ" : '\(.......\)'` # abcABC1