SHELL Command -- get the path and File name: dirnamebasename
Source: Internet
Author: User
SHELL Command & mdash; get path and File name: dirnamebasename to get a file storage path, you can use dirname. There are two scenarios: 1. Full path, for example, aguo @ auto-test :~ & Gt; dirname/home/aguo/insert. SQL/home/aguo # obtain... 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 $
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.