linux - Linux 上的 printf 路径名

标签 linux bash

我正在寻找有关如何使用 getopts 显示不带基名的目录名的信息。 这应该首先为我计算机中的所有 sh 文件提供基本名称、制表符,然后是所有 目录。

例如,如果我这样做:myBashfile.sh -e *sh

我需要看到输出:

test1.sh         /home/directory5/directory6
test60.sh        /home/directory50/directory6
anothertest.sh   /home/directory5/directory6

目前我有这个:

while getopts b opt
 do
      case $opt in
        b) find / -name  $OPTARG -printf "%f\n"-print 2>/dev/null    ;;
       esac
done

只显示这个:

test1.sh
test60.sh
anothertest.sh

最佳答案

-printf "%-20f %h" 怎么样?

关于linux - Linux 上的 printf 路径名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10960685/

相关文章:

c - 如何避免物理磁盘 I/O

ruby-on-rails - 命令 'rails server' 不工作或 Rails 服务器命令不工作

linux - 如何使用带有用户输入的 xxd 获得位输出

Linux Bash 脚本 - 想要在执行其他任务时在控制台上运行秒表

c++ - 缺少关于 "int main(int argc, char* argv[])"的知识

尽管管道坏了,Bash 并没有结束循环

linux - 在 AIX 上使用 bash 执行 "df"命令

ruby - gem 可执行文件将不会运行

php - 子进程与主进程分开 bash shell php

regex - 使用正则表达式的 JQ 搜索对象