DALLASCAO.COM

Site of Cao Shouguang, English to Chinese translator


Warning: Missing argument 1 for shapeshifter_archive_page_title(), called in /var/www/dallascao.com/en/wp-content/themes/shapeshifter/category.php on line 10 and defined in /var/www/dallascao.com/en/wp-content/themes/shapeshifter/includes/functions-do-actions.php on line 142

Category: World Wide Web

sed regular expressions

sed regular expressions
echo 'iweigh297lbs' | sed 's/.*[^0-9]\([0-9]\+\).*/\1/' The expression has to match the whole line. Greed: The expression will match the largest possible from left to right. This won’t work. echo 'iweigh297lbs' | sed 's/.*\([0-9]\+\).*/\1/' Output 7 This won’t work echo 'iweigh297lbs' | sed 's/.*[^0-9]\([0-9]*\).*/\1/' This works echo 'iweigh297lbs' | sed 's/.*[^0-9]\([0-9][0-9]*\).*/\1/' + has to be escaped. […]Read More

sudo: allow non-root users run certain commands

sudo: allow non-root users run certain commands
Allow user www-data to run ps www-data ALL = NOPASSWD: /bin/psRead More

Build a Shadowsocks server – an easier alternative to VPN

Build a Shadowsocks server – an easier alternative to VPN
WARNING: An extra port 998 is also opened for shadowsocks service. I am being lazy so that I do not have handle exceptions when writing add/remove port scripts. Edit config.json and remove the port if you are worried. Last time I wrote a tutorial on how to build an PPTP server. Now a new way […]Read More

use sed to extract a substring using regular expressions

use sed to extract a substring using regular expressions
echo 'nice12343game' | sed -n 's/nice\(.*\)game/\1/p' OUTPUT: 12343 Notice the parenthesis signs need to be escaped inside the sed expression.Read More

use sed to output block of text

use sed to output block of text
sed -n '/^forward-socks5.*$/, /^show-on-task-bar/p' config > config_bakRead More