Practical shell command memo

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.