linux - 比较 txt 文件中的两个目录和输出与 linux 中不同的文件名

标签 linux shell

我试图在 linux shell 中使用这些命令来区分两个目录并在 txt 文件中写入只有不同文件名的输出

diff -qr directory1/ directory2/ | sort > output.txt

它在 output.txt 文件中给我输出,例如

Files directory1/1.txt and directory/1.txt differ

我只需要输出 1.txt 作为输出

有什么想法吗,我只能得到不同的文件名作为 txt 文件的输出。

谢谢

谢谢

最佳答案

只需使用:

diff -ur --brief dir1 dir2 | sed -e 's/Files dir1\///' -e 's/and .*//'

关于linux - 比较 txt 文件中的两个目录和输出与 linux 中不同的文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24680125/

相关文章:

linux - 尝试执行给定命令,这是在 Linux 上的 Kaa 开发平台上使用 ESP8266 设备的步骤之一

android - Android 上的 ifconfig 和 route 命令

linux - 提取 message.log 文件中部分时间戳的 Shell 脚本程序

git - 允许代理转发使用 Cmder (ConEmu)

linux - 如何在 Elastix 模块中包含 javascript

android - 如何从 bash 构建 Xabber?

bash - 如何将文本从一个 Vim 文件复制/粘贴到另一个 shell 选项卡中的另一个 Vim 文件?

linux - 从日志文件中搜索并打印特定数字

linux - Unix - 文件名开头的空格

c - posix_spawn Linux : How to make children processes not enter zombie state when terminating