Linux dirname, basename (RPM)

Source: Internet
Author: User

First, use the--HELP parameter to see it. basename command parameters are very small and easy to master.

$ basename--help

Usage examples:
$ basename/usr/bin/sort Output "sort".
$ basename./include/stdio.h. H Output "stdio".

To specify a path for basename, the basename command deletes all prefixes including the last slash ('/') character, and then displays the string.

basename command format:
basename [pathname] [suffix]
basename [string] [suffix]

Suffix is a suffix, and if suffix is specified, basename will remove suffix from pathname or string.

Additional additions:
1. [Email protected]
[Email protected] is the parameter passed
2, $#
$# the number of parameters to pass
3, $?
is a shell variable that represents the exit state of the last execution command, and generally 0 indicates success, and a non-0 value indicates no success.
Remember:
$? Always represents the exit state of the shell command after the last execution, and when the function is finished, if another command is executed, then $? no longer represents the state after the function is executed, but indicates the exit state of the other command.
4, $!
Represents PID, Process ID
5, $$
Represents ppid, parent process ID

6. $ A represents the shell command itself

Http://blog.chinaunix.net/uid-25505925-id-165025.html

First, dirname directive

1. Function: Remove the file name from the given file name containing the absolute path (part of the non-directory) and return the remaining path (part of the directory)

2. Usage: dirname filename
For example, here are a few examples
(1) # Dirname/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/sysconfig/network-scripts
(2) # dirname/boot/grub/grub.conf
/boot/grub
(3) # Dirname/etc/inittab
/etc
(4) # echo ' pwd ' && dirname modprobe.conf
/etc
.
(5) #echo ' pwd ' && dirname sysconfig/network-scripts/
/etc
Sysconfig
Linux System Management
Second, basename directive

1, Function: Remove the left part of the directory from the given file name containing the absolute path or remove the content of a suffix (part of the directory), then return the remainder (non-directory part)

2. Usage: basename filename [suffix]
For example, here are a few examples
(1) #basename/etc/sysconfig/network-scripts/ifcfg-eth0
Ifcfg-eth0
(2) #basename/boot/grub/grub.conf
Grub.conf
BT4 Hack Wireless Network
(3) #echo ' pwd ' && basename sysconfig/network-scripts/
/etc
Network-scripts
(4) # Basename/boot/grub/grub.conf.bak. bak
Gru

Http://blog.chinaunix.net/uid-25505925-id-165025.html

Linux dirname, basename (RPM)

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.