basename usage in Linux

Source: Internet
Author: User

Function: Remove the directory and suffix of the file

1. Remove the file path

1 basename /backup/jenkins/ci/script/release. SH . bak 2 Release. sh. bak

2. Remove the file suffix

1 basename /backup/jenkins/ci/script/release. SH . bak. bak 2 Release. SH 3 ls 4 Release. SH  Release. SH . bak 5 [email protected]:~/ci/script$

3. Consider the number of suffixes

basename /backup/jenkins/ci/script/release. SH . Bak.old. Oldrelease . SH . Bak[email protected]: basename /backup/jenkins/ci/script/release. SH . Bak.old. old. Bak basename: Extra operand '. Bak'Try 'basename --help' for more information. 

4. Abnormal suffix

1 basename AB b 2 A

5. Other

[Email protected]--printing parameters

$#--Number of printing parameters

$?—— The execution result of the last command/function, 0 for success, not 0 for failure

$!—— pid of the last background run process

$$--the ppid of the last background run process

basename usage in Linux

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.