1. 只是要找文件时,find 很好用
  1. 但是当要删文件时,如果 -exec rm -vrf {} \;
    1. The problem with -exec rm -r {} is that find tries doesn't know that the command deletes the file, so it throws an error when it tries to recurse into the directory. 会存在删了父再访问子的问题。方法是 -depth 设定遍历顺序。
  1. 如果用 -delete ,它会默认 rmdir, 提示非空不能删。
一个方法是 find -type f -deletefind -type d -empty -delete

打包时可以用 /dev/stdin 当输入,然后 install -Dm755 直接输出到 shell 里,一步完成输入内容 + 设定权限。
^ by chatGPT
删除时只删 f 不删 d 可以避免父子问题。用 -not -path 保留某个 folder
install -Dm755 /dev/null $pkgdir/usr/bin/rubick2 echo "#!/bin/bash" >$pkgdir/usr/bin/rubick2 echo "electron13 /opt/rubick2/resources/app.asar" >>$pkgdir/usr/bin/rubick2 make these 3 line of code shorter.
 
but it's not exectuable
 
can it be in one command?
 
use install -Dm755
then chatGPT gives what I want.

有时我们想对整个 find 出的文件做一些事. 比如覆盖内容, 这时不能用 >
重定向会作用在 find 而不是 -exec 后的 bin 上.
解决方法是
这里可以用 bash -c + {} , 但是我被引号转义搞烦了.
清空文件可以
ref
居然还惊动了一位 700k 的史前大佬解答问题.
 
Loading...
Steven Lynn
Steven Lynn
喂马、劈柴、周游世界
最新发布
我与 Dify 的半年
2025-3-9
我的2022年终小结
2024-11-9
记录雅思考试经历与一点学习心得
2024-11-9
Hackergame 2024 思路小结
2024-11-9
黑客松、日本、入职:我的2024下半年的总结
2024-11-9
NotionNext:基于Notion和NextJS的开源博客
2024-11-9