SHELL Command -- get the path and file name: dirname basename

Source: Internet
Author: User

SHELL Command -- get path and file name: dirname basename to get a file storage path, you can use dirname. There are two scenarios: 1. Full path, for example, aguo @ auto-test: ~> Dirname/home/aguo/insert. SQL/home/aguo # obtain the directory where the file is located. 2. Only file names are available. For example: aguo @ auto-test: ~> Dirname Environment. indicates that the path is to get a file name in the current directory (remove the suffix). You can use basename. This command seems a little rigid to use. You need to write the complete suffix. Example: aguo @ auto-test: ~> Basename insert. test. SQL test insert. test. SQL aguo @ auto-test: ~> Basename insert. test. SQL insert. test. Of course, dirname and basename have cool Replacement Methods for pure shell. Dirname: aguo @ auto-test: ~> A =/home/aguo/insert. SQL aguo @ auto-test: ~> Echo $ {a %/*}/home/aguo basename: aguo @ auto-test: ~> A = insert. test. SQL aguo @ auto-test: ~> Echo $ {a %. *} insert complex a =/home/aguo/insert. test. SQL # Only Extract files without paths and. A =$ {a %. *} & a =$ {a ### */} & echo $

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.