Last active
August 29, 2015 14:04
-
-
Save bsenduran/3a61071ff55afeac422f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ echo "abc" | |
abc | |
$ echo "abc" | sed 's/b/z/' | |
azc | |
$ echo "abcb" | sed 's/b/z/' | |
azcb | |
$ echo "abcb" | sed 's/b/z/g' | |
azcz | |
$ echo "abc123def" | sed 's/[0-9]/(&)/' | |
abc(1)23def | |
$ echo "abc123def" | sed 's/[0-9]*/(&)/' | |
()abc123def | |
$ echo "abc123def" | sed -r 's/[0-9]+/(&)/' | |
abc(123)def | |
# The original sed did not support the "+" metacharacter. GNU sed does if you use the "-r" command line option, which enables extended regular expressions. | |
$ echo "abc123def" | sed 's/[0-9]/(&)/2' | |
abc1(2)3def | |
$ echo "abc" | sed 's/[a-z]/\U&/' | |
Abc | |
$ echo "abc" | sed 's/[a-z]/\U&/g' | |
ABC | |
$ echo "abc" | sed 's/[a-z]/\U&/2g' | |
aBC | |
$ echo "ABCabc" | sed 's/a/(&)/Ig' | |
(A)BC(a)bc | |
$ echo "hello world" | sed 's/\<./\U&/g' | |
Hello World | |
# please check 'Additional GNU Extension' in http://www.regular-expressions.info/gnu.html | |
$ echo -e "abc\npqr" | |
abc | |
pqr | |
$ echo -e "abc\npqr" | sed 's/b/z/' | |
azc | |
pqr | |
$ echo -e "abc\npqr" | sed 's/b/z/p' | |
azc | |
azc | |
pqr | |
$ echo -e "abc\npqr" | sed -n 's/b/z/' | |
$ echo -e "abc\npqr" | sed -n 's/b/z/p' | |
azc | |
# remove commented line from a configuration file | |
$ sed -e 's/#.*//' -e '/^$/ d' squid.conf > tem_squid.conf | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment