看板 Perl 關於我們 聯絡資訊
哈囉,大家好, 最近剛接觸perl, 想請問如何移除file.txt 裡面以#開頭的行呢? 謝謝 open FILE, "</pwd/file.txt"; open FILE1, ">new1.pl"; while (<FILE>){ if (/#/){ print FILE1 "$_\t"; } } close FILE -- Sent from my Android -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 223.136.219.56 ※ 文章網址: http://www.ptt.cc/bbs/Perl/M.1420701974.A.243.html ※ 編輯: pat12345 (223.136.219.56), 01/08/2015 15:26:50
DonDonMo: 可以插一行$_=~s/^#//;試試 01/08 18:39
CindyLinz: 等等.. 他應該是想要讓整行不見吧 ^^| 01/08 18:56
CindyLinz: 原 po 把 /#/ 改成 !/^#/ 吧 01/08 18:56
pat12345: ok囉,真是感謝啊^^| 01/08 23:34
herculus6502: perl -pe "s/^#.*//" file.txt > new1.pl 01/09 10:26
xatier: grep -v ^# file 這不用用 Perl 吧 XD 01/09 13:44