Opening Remarks: here we will record some common bash commands, for example, memo and hope to help others solve some problems.
1. Check whether the file exists
if [ -f ./foo.txt ]then echo the file existsfi
2. Check whether the directory exists
if [ -d ./test1 ]thenecho the directory existsfi
3. Make the highlight function always exist
androidyue@ubuntu:~/Desktop$ ls | grep s --color=always | more
4. Use curl to batch download FTP resources
curl -u user:password 'ftp://10.0.1.5/archive/photo/IMG_[8763-9147].JPG' -O
5. Execute the program in the background and add & after the program. Note that there is a space between the two.
androidyue@ubuntu:~/Desktop$ start_eclipse.sh &[1] 3749
6. Get File Information
androidyue@ubuntu:~/Pictures/coding$ file flyweight.png flyweight.png: PNG image data, 723 x 311, 8-bit/color RGB, non-interlaced
7. Make good use of Alias
Use an alias to quickly open common paths, which is simple and efficient. Method: Edit ~ /. Add the following settings to bashrc:
#quick Accessesalias pydir='cd /home/androidyue/osc_git/py_works/'alias shdir='cd /home/androidyue/osc_git/shell_works/'
Save
source ~/.bashrc