Condition and loop

- Make directories listed in a file
This commit is contained in:
bonnie 2020-07-19 22:45:24 +08:00
parent cbe90cb99f
commit f6be60886d

View File

@ -1028,10 +1028,14 @@ if [[ $age -gt 21 ]]
##### For loop
```bash
# Echo the file name under the current directory
for i in $(ls); do echo file $i;done
#or
for i in *; do echo file $i; done
# Make directories listed in a file (e.g. myfile)
for dir in $(<myfile); do mkdir $dir; done
# Press any key to continue each loop
for i in $(cat tpc_stats_0925.log |grep failed|grep -o '\query\w\{1,2\}');do cat ${i}.log; read -rsp $'Press any key to continue...\n' -n1 key;done