相关疑难解决方法(0)

如何"削减"null?

Unix'file'命令有一个-0选项,用于在文件名后输出空字符.据说这对于'cut'来说很有用.

来自man file:

-0, --print0
         Output a null character ‘\0’ after the end of the filename. Nice
         to cut(1) the output. This does not affect the separator which is
         still printed.
Run Code Online (Sandbox Code Playgroud)

(注意,在我的Linux上,不会打印'-F'分隔符 - 这对我来说更有意义.)

如何使用'cut'从'file'的输出中提取文件名?

这就是我想要做的:

find . "*" -type f | file -n0iNf - | cut -d<null> -f1
Run Code Online (Sandbox Code Playgroud)

<null>NUL角色在哪里?

好吧,这就是我想要做的,我想要做的是从目录树中获取具有特定MIME类型的所有文件名.我使用grep(未显示).

我想处理所有合法的文件名,而不是卡在冒号的文件名上,例如,在他们的名字中.因此,NUL会很棒.

我猜非切割解决方案也很好,但我不想放弃一个简单的想法.

unix null cut file nul

11
推荐指数
1
解决办法
4158
查看次数

标签 统计

cut ×1

file ×1

nul ×1

null ×1

unix ×1