linux command tips

635 查看

了解命令的方法

ping为例

which ping
whatis ping
whereis ping
man ping 
type ping

type ping显示

ping is /sbin/ping

type source显示

source is a shell builtin

重载 bash profile

重新载入 profile文件,以免登出再登入终端

source /etc/profile

source命令的作用是运行指定文件的内容作为当前shell的参数,可以用.号代替。
举例,将phantomjs移至/usr/local/bin中,此时用tab键还是无法补全命令,但source之后,tab补全将可用

cat <<EOF 与cat <<-EOF

常见用法是把输入输出到一个文件中,比如scrapy中的示例

cat > myspider.py <<EOF

用这种方法添一行文字到一个新文件很方便。至于不同之处,两者都是获取stdin,并在EOF处结束stdin。但-EOF会去掉所在行前的tab,注意,只是tab,不包括空格