欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

通过实例来熟悉Linux shell中的for循环

程序员文章站 2022-09-15 15:16:20
通过实例来熟悉Linux shell中的for循环 [root@oradoc b]# cat fhv_tripdata_2015-05.csv | split --lines=1000...

通过实例来熟悉Linux shell中的for循环

[root@oradoc b]#  cat fhv_tripdata_2015-05.csv | split --lines=100000  --additional-suffix=.csv
[root@oradoc b]# ls -lrt
total 260780
-rw-r--r--. 1 root root 133469666 Aug 11  2016 fhv_tripdata_2015-05.csv
-rw-r--r--. 1 root root   3026738 Apr  4 00:11 xaa.csv
-rw-r--r--. 1 root root   2900000 Apr  4 00:11 xab.csv
-rw-r--r--. 1 root root   2922463 Apr  4 00:11 xac.csv
-rw-r--r--. 1 root root   3047101 Apr  4 00:11 xad.csv
-rw-r--r--. 1 root root   2941771 Apr  4 00:11 xae.csv
-rw-r--r--. 1 root root   3046756 Apr  4 00:11 xaf.csv
-rw-r--r--. 1 root root   3001381 Apr  4 00:11 xag.csv
-rw-r--r--. 1 root root   2919065 Apr  4 00:11 xah.csv
-rw-r--r--. 1 root root   2958700 Apr  4 00:11 xai.csv
-rw-r--r--. 1 root root   2900000 Apr  4 00:11 xaj.csv
-rw-r--r--. 1 root root   2937201 Apr  4 00:11 xak.csv
-rw-r--r--. 1 root root   2916657 Apr  4 00:11 xal.csv
-rw-r--r--. 1 root root   3006897 Apr  4 00:11 xam.csv
-rw-r--r--. 1 root root   3159065 Apr  4 00:11 xan.csv
-rw-r--r--. 1 root root   3147481 Apr  4 00:11 xao.csv
-rw-r--r--. 1 root root   3173538 Apr  4 00:11 xap.csv
-rw-r--r--. 1 root root   3173419 Apr  4 00:11 xaq.csv
-rw-r--r--. 1 root root   3171995 Apr  4 00:11 xar.csv
-rw-r--r--. 1 root root   3172805 Apr  4 00:11 xas.csv
-rw-r--r--. 1 root root   3173081 Apr  4 00:11 xat.csv
-rw-r--r--. 1 root root   3171008 Apr  4 00:11 xau.csv
-rw-r--r--. 1 root root   3169851 Apr  4 00:11 xav.csv
-rw-r--r--. 1 root root   3171675 Apr  4 00:11 xaw.csv
-rw-r--r--. 1 root root   3172032 Apr  4 00:11 xax.csv
-rw-r--r--. 1 root root   3170691 Apr  4 00:11 xay.csv
-rw-r--r--. 1 root root   3172467 Apr  4 00:11 xaz.csv
-rw-r--r--. 1 root root   3168572 Apr  4 00:11 xba.csv
-rw-r--r--. 1 root root   3171302 Apr  4 00:11 xbb.csv
-rw-r--r--. 1 root root   3168742 Apr  4 00:11 xbc.csv
-rw-r--r--. 1 root root   3114722 Apr  4 00:11 xbd.csv
-rw-r--r--. 1 root root   3171314 Apr  4 00:11 xbe.csv
-rw-r--r--. 1 root root   3173372 Apr  4 00:11 xbf.csv
-rw-r--r--. 1 root root   3170481 Apr  4 00:11 xbg.csv
-rw-r--r--. 1 root root   3174863 Apr  4 00:11 xbh.csv
-rw-r--r--. 1 root root   3169226 Apr  4 00:11 xbi.csv
-rw-r--r--. 1 root root   3174610 Apr  4 00:11 xbj.csv
-rw-r--r--. 1 root root   3168371 Apr  4 00:11 xbk.csv
-rw-r--r--. 1 root root   3173904 Apr  4 00:11 xbl.csv
-rw-r--r--. 1 root root   3169218 Apr  4 00:11 xbm.csv
-rw-r--r--. 1 root root   3170338 Apr  4 00:11 xbn.csv
-rw-r--r--. 1 root root   3171451 Apr  4 00:11 xbo.csv
-rw-r--r--. 1 root root   3172665 Apr  4 00:11 xbp.csv
-rw-r--r--. 1 root root   3062677 Apr  4 00:11 xbq.csv
[root@oradoc b]# ll  x*.csv | wc -l
43
[root@oradoc b]# count=0
[root@oradoc b]# for filename in xa*.csv; do
> echo “abc”$count  
>     (( count++ ))
> done
“abc”0
“abc”1
“abc”2
“abc”3
“abc”4
“abc”5
“abc”6
“abc”7
“abc”8
“abc”9
“abc”10
“abc”11
“abc”12
“abc”13
“abc”14
“abc”15
“abc”16
“abc”17
“abc”18
“abc”19
“abc”20
“abc”21
“abc”22
“abc”23
“abc”24
“abc”25
[root@oradoc b]#