gpt4 book ai didi

linux - bash 编程中的双 for 循环

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

我想用 bash 编程做这样的事情

for file_x in file1, file2, file3, etc...  
for file_y in file1, file2, file3, etc...
if file_y != file_x
do something

有什么建议吗?

最佳答案

#!/bin/bash

for file_x in "file1" "file2" "file3"
do
for file_y in "file1" "file2" "file3"
do
if cmp -q "$file_y" "$file_x"
then
echo "$file_y $file_x are equal"
else
echo "$file_y $file_x are not equal"
fi
done
done

关于linux - bash 编程中的双 for 循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26364434/

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