mirror of
https://github.com/onceupon/Bash-Oneliner
synced 2024-11-25 22:20:17 +00:00
Condition and loop
- Make directories listed in a file
This commit is contained in:
parent
cbe90cb99f
commit
f6be60886d
1 changed files with 5 additions and 1 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue