zoukankan      html  css  js  c++  java
  • linux命令 dirname

    功能: 获取给定路径的目录部分

    利用man 查看dirname的说明如下:

    DESCRIPTION        Output each NAME with its last non-slash component and trailing slashes removed; if NAME contains no /'s, output '.' (meaning the cur‐        rent directory).

           -z, --zero               end each output line with NUL, not newline

           --help display this help and exit

           --version               output version information and exit

    例如:

     hbg@root:/$ dirname /usr/sbin/cron
    /usr/sbin
    hbg@root:/$ dirname /usr/sbin/
    /usr
    hbg@root:/$ dirname /usr/sbin
    /usr

    shell脚本中使用比较多的是 

    cd `dirname $0`

    命令。这个命令的含义是 返回这个脚本文件放置的目录,并可以根据这个目录来定位所要运行程序的相对位置(绝对位置除外)。

  • 相关阅读:
    nuxt.js 学习与记录
    图片上传预览 接收
    k8s之deployment
    k8s之service
    k8s的一些命令
    ansible 学习
    k8s之ConfigMap && secret
    k8s 之Job/CronJob
    k8s之PV & PVC
    配置ssh免密登录
  • 原文地址:https://www.cnblogs.com/rohens-hbg/p/7604839.html
Copyright © 2011-2022 走看看