Grep is one of the most useful command in Linux. "grep" stands for "global regular expression print". Its receives output match the word.
The below command is used for disply the first word or each line in the file.
# grep -Eo '^[^ ]+' file
Simple shell script for grep a single word from specific line,
FINDSTR=$(echo 'The Linux FAQ is one of the best blogs for Linux Admin' | grep -Eo 'The Linux FAQ')
$ echo $FINDSTR
The Linux FAQ
or
Get a word from the file,
grep -Eo 'The Linux FAQ' grepfile.txt
The Linux FAQ
Comments (0)