Bash command and Shell script Summary (8) cyclic article __shell

Source: Internet
Author: User

@WHILE Loop Statement @

V1=1

While ["$v 1"-lt "6"] #注 [and] have spaces around them,-lt have spaces before and after them.

Todo

echo "This is the $v 1 ' showing up"

v1=$ (($v 1+1)) #注意 $ (()) is a mathematical formula

Done

@FOR Loop Statement @

For ((i=1;i<= $LENGTH _extend_days;i++))
Todo

...

Done

For example

Filelist= ""
For ((i=1;i<= $LENGTH _extend_days;i++))
Todo
datei= ' Date +%y%m%d-d $DATE $i days ago '
If [$i-le $LENGTH _days]; Then
file= $OUTPUT _path/$DATEi/1day.txt
Else
file= $OUTPUT _path/$DATEi/1day_one.txt
Fi
If [-s $file]; Then
tempfile= $file. tmpfile
Cat $file |awk-f "\ T"-V delta= $i ' {printf ('%s ', ' $ '; for (i=2; i<=nf;i++) {Split ($i, A, ' | '); printf ("\t%s|%s|%s|%d", a[1],a[2],delta+1,a[3]); printf ("\ n")} ' > $tempfile
filelist= $filelist "" $tempfile
Fi
Done
Sort-m--temporary-directory=./$filelist > $WEEK _merge.imcomplete
MV $WEEK _merge.imcomplete $WEEK _merge
Rm-f $filelist

@ Traverse file in folder @

Index_file_list= ' Ls$index_website_dir '
For Index_file_name in $INDEX _file_list
Todo
index_time=${index_file_name#*.}
cache_file_hourly_output= $CACHE _dir/cache.file. $INDEX _time
Awk-f "\ T" ' {
Cache_map_single_file[$1]=$3
}end{
For (i in Cache_map_single_file)
Printi "T" FILENAME "-" cache_map_single_file[i]
} ' > $CACHE _file_hourly_output $INDEX _website_dir/$INDEX _file_name
Done

@ Traverse file in folder @

filelist= ' ls A '
for filename in $filelist
Todo
Your-command $filename >${filename}.new
Done

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.