iT邦幫忙

0

leetcode with Bash:195. Tenth Line

題目:

Given a text file file.txt, print just the 10th line of the file.

給定一個txt檔,印出裡面的第十行

這......其實就在考我們認不認識awk或sed吧

sed:

sed -n "10p" file.txt

-n表唯讀,但遇到p指令所以印出第十行
最後執行時間35ms(faster than 89.27%)

awk:

awk 'NR==10' file.txt

NR表第幾組資料,我們要第10行所以==10
最後執行時間32ms(faster than 94.25%)

那我們下題見


圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言