我的目录中有大量文件及其其他语言的翻译。有 10 种不同语言的文件和 2 或 3 种不同语言的文件。文件的典型名称是 xx_xxxx_EN.html
及其翻译 xx_xxxx_IT.html 。我想提取一个包含文件名的 2 列 txt 文件。例如,对于英语 - 意大利语语言对:
xx_xxxx_EN.html xx_xxxx_IT.html
最佳答案
#!/bin/bash
ls -1 *EN.html | while IFS= read -r file
do
ls -1 ${file%_*}* | while IFS= read -r match
do
if [ "$file" != "$match" ]; then
echo "$file" "$match"
fi
done
done
<小时/>
$ ls *html
01_DE.html 01_EN.html 01_ESP.html 01_IT.html 02_EN.html 02_IT.html 02_PL.html
$ ./pair.sh
01_EN.html 01_DE.html
01_EN.html 01_ESP.html
01_EN.html 01_IT.html
02_EN.html 02_IT.html
02_EN.html 02_PL.html
关于python - Linux 中的配对文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13961930/