小编Lui*_*uis的帖子

查找:将 -depth 与 -prune 结合以提供 cpio

我正在构建一个备份脚本,其中某些目录不应包含在备份存档中。

cd /;
find . -maxdepth 2 \ 
    \( -path './sys' -o -path './dev' -o -path './proc' -o -path './media' -o -path './mnt' \) -prune \
-o -print
Run Code Online (Sandbox Code Playgroud)

这只会找到我想要的文件和目录。

问题是cpio应该提供以下选项,以避免在恢复文件时出现权限问题。

find ... -depth ....
Run Code Online (Sandbox Code Playgroud)

如果我添加该-depth选项,返回的文件和目录将包含我想要避免的文件和目录。

我真的不明白查找手册中的这些句子:

-prune True;  if  the  file is a directory, do not descend into it. If
              -depth is given, false; no  effect.   Because  -delete  implies
              -depth, you cannot usefully use -prune and -delete together.
Run Code Online (Sandbox Code Playgroud)

find

6
推荐指数
1
解决办法
1793
查看次数

替代 xmllint 来检查 xml 有效性

有时,我必须根据 xsd 文件检查一些大型 xml 文件的有效性。我收到的最大 xml 文件的大小接近 1.5GB。 xmllint占用了我所有的 RAM 和几乎所有的交换空间,总内存使用量为 18GB。因此,验证过程持续了 24 小时。

我的问题:是否有替代方案xmllint --schema消耗更少的内存,也许利用一些流功能而不是将文件加载到内存?

linux xml

5
推荐指数
1
解决办法
5646
查看次数

以另一个非 root 用户身份运行 sudo 并保存在该用户的主目录中

我添加了一个新组:ircuser和一个新用户:ircuser

visudo我放置这一行:

myuser localhost=(ircuser) NOPASSWD: /usr/bin/irssi
Run Code Online (Sandbox Code Playgroud)

创建的ircuser目录,应保存配置文件、缓存等:

drwxrwx--- 2 ircuser ircuser 4096 Mar  2 10:28 ircuser
Run Code Online (Sandbox Code Playgroud)

发出命令时:

sudo -Hu ircuser /usr/bin/irssi
Run Code Online (Sandbox Code Playgroud)

或者

sudo -u ircuser /usr/bin/irssi
Run Code Online (Sandbox Code Playgroud)

程序无法将配置文件保存在ircuser目录中。

** ERROR **: Couldn't create /home/myuser/_web/ircuser/.irssi directory
aborting...
Aborted
Run Code Online (Sandbox Code Playgroud)

但是,它正在运行ircuser

ps auxw | grep irssi
ircuser  11962  0.0  0.0  23684  2504 pts/6    S+   11:18   0:00 /usr/bin/irssi
Run Code Online (Sandbox Code Playgroud)

那么,尽管irssi运行ircuser它不能写入同一用户拥有的目录?我需要更改什么才能让它保存在那里?

permissions sudo files

4
推荐指数
1
解决办法
2万
查看次数

标签 统计

files ×1

find ×1

linux ×1

permissions ×1

sudo ×1

xml ×1