Лс
Size: a a a
Лс
️
./test1.sh {1..10}
There are 10 arguments
2
4
6
8
Лс
Лс
️
➜ ~ cat test1.sh
#!/bin/bash
set -efu
printf "There are %d arguments\n" "$#"
echo "$@" | grep -P -o "\d*[0,2,4,6,8]\W" -
➜ ~ cat test2.sh
#!/bin/bash
set -efu
n=1
printf "There are %d arguments\n" "$#"
for arg in "$@"
do
if [ "$((n % 2))" -eq 0 ]; then
printf "%s\n" "${arg}"
fi
n=$(($n + 1))
done
Лс
Лс
Лс
аᶘ
аᶘ
for i in $(seq 1 $#); do printf "%s\n" "$(eval echo "\$${i}")"; done`
F
printf
в шелл — это калька с printf'а из libc, позволяет печатать в stdout с заданным форматом.аᶘ
F
Here is a table that summarizes the various conversion specifications:
‘%d’
Matches an optionally signed integer written in decimal. *Note
Numeric Input Conversions::.
аᶘ
Here is a table that summarizes the various conversion specifications:
‘%d’
Matches an optionally signed integer written in decimal. *Note
Numeric Input Conversions::.
F
аᶘ
F
аᶘ
️