zoukankan      html  css  js  c++  java
  • linux shell dirname basename

    [root@hadoopname ~]# clear
    [root@hadoopname ~]# ll
    total 136
    -rw-------. 1 root root  2696 Jun 24 04:41 anaconda-ks.cfg
    drwxr-xr-x. 2 root root  4096 Jun 24 06:13 Desktop
    drwxr-xr-x. 2 root root  4096 Jun 24 06:13 Documents
    drwxr-xr-x. 2 root root  4096 Jun 24 06:13 Downloads
    -rwxr-xr-x. 1 root root    32 Dec  6 13:20 first
    -rw-r--r--. 1 root root 39935 Dec  5 17:38 i.log
    -rw-r--r--. 1 root root 39935 Jun 24 04:40 install.log
    -rw-r--r--. 1 root root 10175 Jun 24 04:38 install.log.syslog
    drwxr-xr-x. 2 root root  4096 Jun 24 06:13 Music
    drwxr-xr-x. 2 root root  4096 Jun 24 06:13 Pictures
    drwxr-xr-x. 2 root root  4096 Jun 24 06:13 Public
    drwxr-xr-x. 2 root root  4096 Jun 24 06:13 Templates
    drwxr-xr-x. 2 root root  4096 Jun 24 06:13 Videos
    [root@hadoopname ~]# pwd
    /root

       #  dirname: 取一个文件的存储路径,分两种情况

    #仅仅是个文件名的
    [root@hadoopname ~]# dirname first 
    .
    #带绝对路径
    [root@hadoopname ~]# dirname /root/first
    /root
    [root@hadoopname ~]# 
    dirname: 取一个文件的存储路径,分两种情况
    #仅仅是个文件名的
    #带绝对路径
     

    basename:取一个文件的文件名

    想要去掉后缀名的话 要将 后缀名 做为参数加在后面
    [root@hadoopname ~]# basename i.log 
    i.log
    [root@hadoopname ~]# basename i.log log
    i.
    [root@hadoopname ~]# 
     
  • 相关阅读:
    poj 2251
    poj 1321
    poj 2777
    poj 3468
    poj 2318
    javascript
    buhui
    swift 构造器
    mac上不了网
    字体
  • 原文地址:https://www.cnblogs.com/xuxianhong/p/shell.html
Copyright © 2011-2022 走看看