gpt4 book ai didi

python - Linux 中的配对文件

转载 作者:太空宇宙 更新时间:2023-11-04 06:05:18 24 4
gpt4 key购买 nike

我的目录中有大量文件及其其他语言的翻译。有 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com