NBash
53 строки · 979.0 Байт
1#!/bin/bash
2
3# Цикл for in
4
5some_array=(one 2 three 4 five "si@x" seven 'eight%' nine ten 'He&$\llo my friend!')6readonly some_array7
8for item in "${some_array[@]}"9do
10echo "$item"11done
12
13echo "--------------------------------"14for item in "${some_array[@]}"15do
16if [[ ${#item} -eq 3 ]]17then18echo "$item Длина строки равна 3"19else20echo "$item Длина строки не равна 3"21fi22done
23
24echo "--------------------------------"25for item in "${some_array[@]}"26do
27if [[ $item =~ [@#$%\&*+=-] ]]28then29echo "$item - содержит спецсимволы"30fi31done
32
33echo "--------------------------------"34readonly PATH_FOR_CHECK="/home/stas0n/Загрузки/Test"35
36for item in "$PATH_FOR_CHECK"/*37do
38if [ -d "$item" ]39then40echo "$item"41fi42done
43
44
45echo "--------------------------------"46new_array=()47
48for ((i = 100; i >=0; i--))49{
50new_array+=("$i")51}
52
53echo "${new_array[@]}"54
55