Pages

2011年2月16日 星期三

我的Shell Script學習心得(二):cut的使用

以下記錄我練習寫的一個小程式,可以讀取出file1第1行記錄的日期資訊。
#This code was written by Uncle on 2011/02/15
#This code can Add a new line on file1, and Update Date information
#in the first line.
#!bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH

tmp=`head -1 file1|cut -c 17-24`
echo $tmp
----------------------------------------
其中file1內容:
>Last Update on 20110215
Data1 by Peter
Data2 by Mary

執行結果:
$sh test3.sh
20110215

沒有留言:

張貼留言