美文网首页
linux029 basename & dirname

linux029 basename & dirname

作者: caoqiansheng | 来源:发表于2020-09-13 20:15 被阅读0次

basename

1.1 语法
Usage: basename NAME [SUFFIX]
  or:  basename OPTION... NAME...
Print NAME with any leading directory components removed.
If specified, also remove a trailing SUFFIX.

Mandatory arguments to long options are mandatory for short options too.
  -a, --multiple       support multiple arguments and treat each as a NAME
  -s, --suffix=SUFFIX  remove a trailing SUFFIX; implies -a
  -z, --zero           end each output line with NUL, not newline
      --help     display this help and exit
      --version  output version information and exit

Examples:
  basename /usr/bin/sort          -> "sort"
  basename include/stdio.h .h     -> "stdio"
  basename -s .h include/stdio.h  -> "stdio"
  basename -a any/str1 any/str2   -> "str1" followed by "str2"

GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
Report basename translation bugs to <https://translationproject.org/team/>
Full documentation at: <https://www.gnu.org/software/coreutils/basename>
or available locally via: info '(coreutils) basename invocation'
1.2 举例
# 取末尾的文件名或路径名
basename /mnt/e/Work/bioinfo/project/202009_RNAseq/RNAseq\ Pipline
# RNAseq Pipline
# 取末尾的文件名或路径名,并删除扩展名
cqs@cqs:/mnt/e/Work/bioinfo/project/202009_RNAseq$ basename /mnt/e/Work/bioinfo/project/202009_RNAseq/RNAseq\ Pipline  Pipline

2 dirname

2.1 语法
Usage: dirname [OPTION] NAME...
Output each NAME with its last non-slash component and trailing slashes
removed; if NAME contains no /'s, output '.' (meaning the current directory).

  -z, --zero     end each output line with NUL, not newline
      --help     display this help and exit
      --version  output version information and exit

Examples:
  dirname /usr/bin/          -> "/usr"
  dirname dir1/str dir2/str  -> "dir1" followed by "dir2"
  dirname stdio.h            -> "."

GNU coreutils online help: <https://www.gnu.org/software/coreutils/>
Report dirname translation bugs to <https://translationproject.org/team/>
Full documentation at: <https://www.gnu.org/software/coreutils/dirname>
or available locally via: info '(coreutils) dirname invocation'
2.2 举例
# dirname命令去除文件名中的非目录部分,仅显示与目录有关的内容
dirname /mnt/e/Work/bioinfo/project/202009_RNAseq/RNAseq\ Pipline
# /mnt/e/Work/bioinfo/project/202009_RNAseq
# RNAseq

相关文章

网友评论

      本文标题:linux029 basename & dirname

      本文链接:https://www.haomeiwen.com/subject/yxsoektx.html