Bash pattern match

1. 起因:Shell 获取文件名和后缀名 [_posts] ==>> file="A-Tale-Of-Two-Cities.pdf" [_posts] ==>> echo "${file%.*}" A-Tale-Of-Two-Cities [_posts] ==>> echo "${file##*.}" pdf 2. 基于 Pattern Matching 的子串替换 ${str/$old/$new} 替换第一个。 ${str//$old/$new} 替换所有。 注意:不能使用正则表达式,只能使用 ?* 的Shell扩展。只能用shell通配符如 *? [list] [!list] [a-z]。 ...

January 1, 2016 · 1 min · mousepotato

Linux 下的几个文件

Linux 下的几个文件 Unix或者类 Unix系统/dev下有几个很特殊的文件.他们就是: 1: /dev/null 这个/dev下放的是系统和用户的设备文件. null是个文件名. 被称为 the null device, /dev/null 这个童鞋脾气有点大,听不见别人任何话,所以呢任何话传到他耳朵里都被当成耳旁风了.当然更可恨的是他竟然还假惺惺的点头说听到了.当然他是很诚实地说的. ...

June 13, 2013 · 2 min · mousepotato

How to download a whole website using wget with chinese character support

如何使用wget下载整个网站同时支持中文命名 wget 下载整个网站 使用命令: wget -r -p -E -k -nH -np --cut-dirs=1 -P /path/to/save/ Website URL 支持中文 vi ~/.wgetrc 添加如下内容: --restrict-file-names=nocontrol --trust-server-names=on --content-disposition=on That’s it!!

April 28, 2013 · 1 min · mousepotato