我正在寻找具有不同文件扩展名的重复文件名。
这是我运行的命令:
find -maxdepth 2 -type f \( -name "*.avi" -or -name "*.mkv" -or -name "*.mp4" -or -name "*.mpg" -or -name "*.MP4" -not -name '*~' \) | sort > ~/sorted.txt
以下是示例输出(以 为单位sorted.txt
):
./Avengers- Age of Ultron (2015)/Avengers- Age of Ultron (2015).mp4
./Beetle Juice (1988)/Beetle Juice (1988).avi
./Clerks II (2006)/Clerks II (2006).avi
./Death Race (2008)/Death Race (2008)-pt1.avi
./Death Race (2008)/Death Race (2008)-pt2.avi
./Death Race 2 (2010)/Death Race 2 (2010).mp4
./Into the Wild (2007)/Into the Wild (2007).avi
./Into the Woods (2014)/Into the Woods (2014).mkv
./Into the Woods (2014)/Into the Woods (2014).mp4
./Pink Floyd The Wall (1982)/Pink Floyd The Wall (1982).avi
./The Big Lebowski (1998)/The Big Lebowski (1998).avi
./The Gods Must Be Crazy (1980)/The Gods Must Be Crazy (1980).avi
./The NeverEnding Story (1984)/The NeverEnding Story (1984).avi
./The NeverEnding Story (1984)/The NeverEnding Story (1984).mpg
./Winnie the Pooh (2002)/Winnie the Pooh (2002).avi
我想修剪写入的输出sorted.txt
:
./Into the Woods (2014)/Into the Woods (2014).mkv
./Into the Woods (2014)/Into the Woods (2014).mp4
./The NeverEnding Story (1984)/The NeverEnding Story (1984).avi
./The NeverEnding Story (1984)/The NeverEnding Story (1984).mpg
即我拥有多份副本的标题。更好的方法是这样的,但上面的方法也可以:
Into the Woods (2014)
The NeverEnding Story (1984)
注意:文件名中会有空格、破折号 ( -
)、撇号 ( '
) 和括号 ((
和)(但文件名中不能有逗号 ( )、双引号 ( ) 或下划线 ( )。此外,最终输出是供眼睛阅读的,因此不必很漂亮。我只需要能够快速手动识别重复项。)
,
"
_
答案1
尝试这个:
rev < sorted.txt | cut -d . -f 2- | cut -d / -f 1 | rev | uniq -d
输出:
森林深处(2014) 永无止境的故事(1984)