“Bash for Loop” Kod odpowiedzi

Shell dla pliku w katalogu

# Basic syntax:
for file in /directory/*
do
	echo $file
done
# Where:
#	- the echo command is run on each file found using the search pattern 
#		(here, all files in the /directory/ folder)

# Example usage:
# Say you have the directory "/my/favorite/files" with the following files:
test.txt
my.txt
code.png

for file in /my/favorite/files/*.txt; do
	echo $file
done
--> test.txt
--> my.txt
# Note, code.png isn't printed because it doesn't match the search pattern
Charles-Alexandre Roy

dla pętli w skrypcie Shell

for i in {1..5}
do
   echo "Welcome $i times"
done
Cruel Capybara

Bash pętli

years=(2018 2019)
days=(74 274)

for year in "${years[@]}"; do
    for day in $(seq -w ${days[0]} ${days[1]}); do
               echo $year
               echo $day
    done
done
Tremendous Enceladus

Dla pętli w skrypcie Shell

for i in `seq 1 10`
do
	echo $i #Do something here.
done
Difficult Dragonfly

Bash for Loop

for ((i = 1; i <= 10 ; i++)); do
  echo $i
done
Big Breasted Blue-eyed Baby Badgers Beating Band

Bash for Loop

#!bin/bash

for i in {1..5}
do
    echo i:$i
done
agentTequila

Odpowiedzi podobne do “Bash for Loop”

Pytania podobne do “Bash for Loop”

Więcej pokrewnych odpowiedzi na “Bash for Loop” w Shell/Bash

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu