Проблема новичка в командах и каналах оболочки UNIX - PullRequest
0 голосов
/ 09 марта 2011

это материал из курса. Из моего исследования код всегда начинается с Шебанга

#! /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".

1 Ответ

0 голосов
/ 09 марта 2011

1-е задание

head -n 199 $FILE | tail -n 100 | grep "hello" | wc -l

2-е задание

head -n 199 $FILE | tail -n 100 | grep "hello, " | grep -v "hello, world" | wc -l
...