linux for 的用法总结

 one line

for file in $(ls *.gz); do  gunzip -c $file > ${file%%.*}  ;done

shell

#!/bin/bash  
  
for((i=1;i<=100;i++));  
do   
echo $(expr $i \* 3 + 1);  
done
#!/bin/bash  
  
for i in $(seq 1 100)  
do   
echo $(expr $i \* 3 + 1);  
done
#!/bin/bash  
  
for i in {1..100}  
do  
echo $(expr $i \* 3 + 1);  
done
#!/bin/bash  
  
list="where are you from"  
for i in $list;  
do  
echo "$i is ok";  
done
#!/bin/bash  
  
for i in f1 f2 f3 ;  
do  
echo $i is ok ;  
done
#!/bin/bash  
  
for file in /var/*;  
do  
echo $file is file path \! ;  
done
posted on 2020-05-21 18:34  InnoLeo  阅读(14368)  评论(0编辑  收藏  举报