歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> SHELL編程 >> 實用Shell命令備忘

實用Shell命令備忘

日期:2017/2/28 14:46:09   编辑:SHELL編程

開場白:這裡簡單記錄一些常用的bash命令,一則備忘,二來希望可以幫助別人解決一些問題。

1.檢測文件是否存在

if [ -f ./foo.txt ]

then

echo the file exists

fi

2.檢測目錄是否存在

fi

if [ -d ./test1 ]

then

echo the directory exists

fi

3.讓高亮功能一直存在

www.linuxidc.com @Ubuntu:~/Desktop$ ls | grep s --color=always | more

4.使用curl批量下載ftp資源

curl -u user:password 'ftp://10.0.1.5/archive/photo/IMG_[8763-9147].JPG' -O

5.後台執行程序,在程序後加上&,注意兩者之間有一個空格

www.linuxidc.com @ubuntu:~/Desktop$ start_eclipse.sh &

[1] 3749

6.獲取文件信息

www.linuxidc.com @ubuntu:~/Pictures/coding$ file flyweight.png

flyweight.png: PNG image data, 723 x 311, 8-bit/color RGB, non-interlaced

Copyright © Linux教程網 All Rights Reserved