Linux簡介及常用命令使用5--linux shell編程入門,5--linux編程入門

來源:互聯網
上載者:User

Linux簡介及常用命令使用5--linux shell編程入門,5--linux編程入門

產生 測試資料的shell指令碼
Vim data_create.sh

rm -rf ./data.txt
touch data.txt
for((i=0;i<2000;i++))
do
str=',name';
name=${i}${str}${i}

#echo $name
echo $name>> data.txt
done

echo 'show testdata'
more data.txt

chmod u+x data_create.sh
運行指令碼
sh -x data_create.sh


crontab 定時任務執行shell
crontab -e 修改目前使用者
crontab -l 查看
crontab -l -u root/mysql 查看某個使用者的定時任務

格式:分 時 日 月 星期 要啟動並執行命令
第一列分鐘1-59
第二列小時0-23 【0 就是24點】
第三列日1-31
第四列是月 1-12
星期幾0-6【0是星期天】


* 表示 忽略該屬性

20 * * * * cd /root/makaidong_com/file && sh -x fordata.sh >> fordata.log 2>&1

&
shell while迴圈:10以內的和=55
#!/bin/bash
sum=0
i=1

while(( i <= 10))
do
let "sum+=i" //sum = sum+i
let "i += 1" //i=i+1
done
echo "sum=$sum"


tar
Linux壓縮/解壓縮
gzip -r
gzip -c *.11.txt > filename.gz
Linux解壓縮保留源檔案的方法:
gunzip filename.gz > filename

 

 

 


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.