AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-81700

markling's questions

Martin Hope
markling
Asked: 2022-05-25 15:15:54 +0800 CST

如何从命令行查找垃圾箱中文件的删除日期

  • 0

我想恢复我不小心删除的文件。我不能去垃圾桶/废纸篓文件夹并简单地恢复文件,因为我不知道文件是什么。当屏幕焦点位于 Thunar 窗口时,我不小心按了删除键将其删除。(当您使用机械键盘和人类手指时,这是一个特别危险的问题)。

Thunar 不显示删除的日期,因此无法简单地对垃圾箱/废纸篓文件夹中的文件进行排序。

但是,如果我右键单击废纸篓中的已删除文件并查看文件属性,我会发现废纸篓中的文件确实具有“已删除”日期属性。

如何在终端中按删除日期列出文件。以及如何在终端中打开废纸篓文件夹?

如果废纸篓文件夹是虚拟的,并且给定删除日期的文件属性存储在其他地方,那么那个地方在哪里以及如何查询它?(我看到,如果我查看~/.local/share/Trash/files/,它看起来与您从 Thunar 侧面板图标导航到的废纸篓中的文件相同。但是~/.local/share/Trash/files/当您正确时,其中的文件没有“已删除”日期作为属性-点击查看它们的属性)。

symlink date
  • 1 个回答
  • 88 Views
Martin Hope
markling
Asked: 2022-03-28 06:51:20 +0800 CST

使用可选的带括号的参数查找

  • 0

如何添加可选的分组参数列表来查找?

例如,使用一组基本参数来定义将始终找到的文件,而不管指定了哪些其他变量条件。

# args to find any files ending _count or _scan

._. fargs=( -type f -name '*_count' -o -name '*_scan' )
._. cd /sys/fs/ext4/sda1
._. find . \( "${fargs[@]}" \) 2> /dev/null
./mb_min_to_scan
./errors_count
./mb_max_to_scan
./msg_count
./warning_count

添加可选的附加参数

._. fpterm=warning
._. fpterm2=max
._. fANDargs=( -ipath "*$fpterm*" -o -ipath "*$fpterm2*" )

应用括号中的可选参数以使用以下形式执行查找:( a 或 b 或 c )和( d 或 e 或 f )

._. find . \( "${fargs[@]}" \) \( "${fANDargs[@]}" \) 2> /dev/null
./dm-1/mb_max_to_scan
./dm-1/warning_count
./dm-0/mb_max_to_scan
./dm-0/warning_count
./sda1/mb_max_to_scan
./sda1/warning_count

但是当可选的 arg 数组为空时,它会停止满足其他条件,并且根本找不到文件:

._. fANDargs=()
._. find . \( "${fargs[@]}" \) \( "${fANDargs[@]}" \) 2> /dev/null
._. 

空括号导致问题:

._. find . \( "${fargs[@]}" \) \( \) 2> /dev/null
._.

而通常,一个空的 arg 数组不会阻止满足其他条件:

._. fANDargs=()   
._. echo "${fANDargs[@]}"

._. find . \( "${fargs[@]}" \) "${fANDargs[@]}" 2> /dev/null
...
./sda1/mb_min_to_scan
./sda1/errors_count
./sda1/mb_max_to_scan
./sda1/msg_count
./sda1/warning_count

因此,如果仅当可选 args 数组不为空时才可以添加方括号,则该命令可能会起作用。

但是如何有条件地添加括号呢?

将括号添加到数组时似乎不起作用,例如:

._. fpterm=warning
._. fANDargs=()
._. [ ! -z $fpterm ] && fANDargs+=( '\(' -ipath "*$fpterm*" '\)' )
._. echo "${fANDargs[@]}"
\( -ipath *warning* \)
._. find . \( "${fargs[@]}" \) "${fANDargs[@]}" 2> /dev/null
._.
bash find
  • 1 个回答
  • 30 Views
Martin Hope
markling
Asked: 2019-11-06 02:40:56 +0800 CST

为什么这些 rsync 过滤器参数在数组中传递时会在 bash 中失败?

  • 0

为什么这个 rsync 命令在我按字面意思给出时起作用,但在我从变量创建时不起作用?

这是变量 - 首先是我作为数组传递给 rysnc 的选项:

$ echo "${options[@]}"
-av --prune-empty-dirs -f "- *.flac" -f "- *.WMA" -f "- *.wma" -f "- *.ogg" -f "- *.mp4" -f "- *.m4a" -f "- *.webm" -f "- *.wav" -f "- *.ape" -f "- *.zip" -f "- *.rar"

$ echo ${options[6]}
-f

$ echo ${options[7]}
"- *.wma"

然后是源目录,rsync 是从该目录复制文件:

$ echo "\"$dir/\""
"/media/test/Ahmad Jamal Trio/Live at the Pershing/"

以及 rsync 要将文件复制到的目标目录:

$ echo "\"$target_dir\""
"/home/test/mp3/Ahmad Jamal Trio/Live at the Pershing/"

把它们放在一起:

$ echo "${options[@]}" "\"$dir/\"" "\"$target_dir\""
-av --prune-empty-dirs -f "- *.flac" -f "- *.WMA" -f "- *.wma" -f "- *.ogg" -f "- *.mp4" -f "- *.m4a" -f "- *.webm" -f "- *.wav" -f "- *.ape" -f "- *.zip" -f "- *.rar" "/media/test/Ahmad Jamal Trio/Live at the Pershing//" "/home/test/mp3/Ahmad Jamal Trio/Live at the Pershing/"

这一切看起来都应该如此。事实上,如果您按字面意思给出命令,它确实有效,如下所示:

$ rsync -av --prune-empty-dirs -f "- *.flac" -f "- *.WMA" -f "- *.wma" -f "- *.ogg" -f "- *.mp4" -f "- *.m4a" -f "- *.webm" -f "- *.wav" -f "- *.ape" -f "- *.zip" -f "- *.rar" "/media/test/Ahmad Jamal Trio/Live at the Pershing/" "/home/test/mp3/Ahmad Jamal Trio/Live at the Pershing/"
./
Ahmad Jamal Trio - Live at the Pershing - 01 - But Not for Me.mp3
Ahmad Jamal Trio - Live at the Pershing - 02 - Surrey With The Fringe On Top.mp3
Ahmad Jamal Trio - Live at the Pershing - 03 - Moonlight In Vermont.mp3
Ahmad Jamal Trio - Live at the Pershing - 04 - Music, Music, Music.mp3
Ahmad Jamal Trio - Live at the Pershing - 05 - No Greater Love.mp3
Ahmad Jamal Trio - Live at the Pershing - 06 - Poinciana.mp3
Ahmad Jamal Trio - Live at the Pershing - 07 - Wood'yn You.mp3
Ahmad Jamal Trio - Live at the Pershing - 08 - What's New.mp3
AlbumArtSmall.jpg
AlbumArtLarge.jpg
Folder.jpg

sent 43,194,376 bytes  received 285 bytes  28,796,440.67 bytes/sec
total size is 43,182,454  speedup is 1.00

但是当我使用 vars 作为 args 调用 rsync 时它失败了:

$ rsync "${options[@]}" "\"$dir/\"" "\"$target_dir\""
Unknown filter rule: `"- *.flac"'
rsync error: syntax or usage error (code 1) at exclude.c(902) [client=3.1.2]
bash
  • 1 个回答
  • 301 Views
Martin Hope
markling
Asked: 2017-12-07 11:29:17 +0800 CST

如何将命令应用于带有空格的 $PATH 文件?

  • 0

我的 $PATH 有 /a/path/with 空格/in/it

我只需键入名称即可运行位于所述路径上的可执行文件。

但是当我尝试对它们应用命令时,它们会因找不到错误而失败。

例如。我在路径上有一个 python 脚本,称为 prog.py

如果我只输入 prog.py,我的 shell 会尝试运行它。所以这条路是有效的。但:

$ python3 prog.py

python3: can't open file 'prog.py': [Errno 2] No such file or directory

$ file prog.py

prog.py: cannot open `prog.py' (No such file or directory)

如果我 cd 到 prog.py 的实际位置,然后尝试相同的命令,它们会按预期运行:

$ file ./prog.py

./prog.py: Python script, ASCII text executable

$ python3 ./prog.py

True

为什么会这样?我该怎么做才能从我希望的任何地方执行这些命令(尤其是 python3)?

python path
  • 3 个回答
  • 1226 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve