Computer scienceSystem administration and DevOpsCommand lineText processing

Grep useful options

Display the context

Report a typo

Using -C <n> option, print the search result of the word "pajamas" with 1 line before and 1 line after it from the file /tmp/file.txt.

Sample Input 1:

I made myself a snowball
As perfect as could be.
I thought I’d keep it as a pet
And let it sleep with me.
I made it some pajamas
And a pillow for its head.
Then last night it ran away,
But first it wet the bed.

Sample Output 1:

And let it sleep with me.
I made it some pajamas
And a pillow for its head.
Write a program in Shell
#!/usr/bin/env bash
solve() {
# add your solution here

}
___

Create a free account to access the full topic