Re: [問題] VIM的指令從檔案輸入

看板Linux作者時間16年前 (2009/10/08 05:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
※ 引述《flax00298.bbs@ptt.cc (NI)》之銘言: > 有辦法這樣作到嗎 > 我現在在寫一份作業 > 然後他是有固定規格的一筆資料 > 每隔五行就是一筆完整的DATA > 總共有上千行的話 > 我有沒有辦法用類似LOOP的方式寫個指令 > 然後讓VIM去吃他呢? > 新手發問 > 總覺得自己的問題好像很蠢ORZ... > 先謝謝各位看完小弟的文章=ˇ= 有點說的不清楚,如果是每五行要讀取一份完整的DATA 用Shell Script就可以了啊 類似下面 #!/bin/ksh source_file=<specify your source file name> target_file=<specify your target file name> >$target_file #make sure your target file is empty typeset -i ilinecount=0 cat $source_file|while read line do ilinecount=`expr $ilinecount + 1` each5line=`expr $ilinecount % 5` if [ $each5line -eq 0 ] then echo $line >> $target_file fi done -- ※ Origin: SayYA 資訊站 <bbs.sayya.org> ◆ From: 114-137-101-42.dynamic.hinet.net
文章代碼(AID): #1ApG6FF6 (Linux)
文章代碼(AID): #1ApG6FF6 (Linux)