iTranslated by AI
The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🐟
Loops in fish shell
while loops
Example that keeps displaying "Loop forever"
while true
echo "Loop forever"
end
for loops
Example that generates file_1.txt through file_5.txt all at once
for x in (seq 5)
touch file_$x.txt
end
Example that generates a .bak copy for all .txt files in a folder
for file in *.txt
cp $file $file.bak
end
Discussion