Linux DirName, basename instructions

Source: Internet
Author: User

Http://blog.sina.com.cn/s/blog_9d074aae01013ctk.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
Grub.conf
(5) # Basename/boot/grub/grub.conf.bak. Conf.bak
Grub

Linux DirName, basename instructions

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.