这是课程的材料。根据我的研究,代码将始终以shebang
开头#! /bin/sh
我也想解决这个问题,我可能需要使用
的组合wc, tail, grep, head
但是我把它放在一起很麻烦。非常感谢帮助。
Write a shell command that processes a file
that is 200 lines long or more. It outputs the number of those lines within lines 100 through
199 *inclusive* that contain the character string “hello”.
Write a shell command that outputs the number of lines in the lines range
100..199 that contain "hello, " but is NOT followed by "world".
答案 0 :(得分:0)
第一项任务
head -n 199 $FILE | tail -n 100 | grep "hello" | wc -l
第二项任务
head -n 199 $FILE | tail -n 100 | grep "hello, " | grep -v "hello, world" | wc -l