mirror of
https://github.com/onceupon/Bash-Oneliner.git
synced 2024-11-29 15:46:35 +00:00
Condition and loop
- Make directories listed in a file
This commit is contained in:
parent
cbe90cb99f
commit
f6be60886d
@ -1028,10 +1028,14 @@ if [[ $age -gt 21 ]]
|
|||||||
|
|
||||||
##### For loop
|
##### For loop
|
||||||
```bash
|
```bash
|
||||||
|
# Echo the file name under the current directory
|
||||||
for i in $(ls); do echo file $i;done
|
for i in $(ls); do echo file $i;done
|
||||||
#or
|
#or
|
||||||
for i in *; do echo file $i; done
|
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
|
# 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
|
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 New Issue
Block a user