小编M S*_*lle的帖子

如何"削减"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
查看次数

在 Windows 和 WSL 之间共享 git repo 符号链接

我有以下设置:

  • WSL 与 Ubuntu 一起安装,git 已经安装在那里
  • 在 Windows 端从https://git-scm.com安装的 git
  • 通过打开开发人员模式并将我的用户添加到正确的策略组来启用符号链接创建,如https://github.com/git-for-windows/git/wiki/Symbolic-Links 所述
  • core.symlinks=true (由于上面的线)
  • core.autocrlf=false (我不想让 git 做任何聪明的事,我在 Windows 和 WSL 之间共享 repo)

几乎完美无缺(印象非常深刻)。当我克隆一个存储库时,在 Windows 和 WSL 中都可以,除了两侧之一的符号链接说它们被修改但它们没有。在两侧,符号链接都可以正常工作,我可以毫无问题地导航它们。

初始克隆(在 Windows 端)后,Windows PowerShell 提供:

PS C:\Users\Matthew\Projects\...> git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean
Run Code Online (Sandbox Code Playgroud)

但是,在 WSL 方面,它表示修改了两个符号链接:

/mnt/c/Users/Matthew/Projects/...$ git status 
On branch master 
Your branch is up to date with 'origin/master'. …
Run Code Online (Sandbox Code Playgroud)

git windows-subsystem-for-linux

8
推荐指数
2
解决办法
4225
查看次数

标签 统计

cut ×1

file ×1

git ×1

nul ×1

null ×1

unix ×1

windows-subsystem-for-linux ×1