file.txt is as below :
gui : 789
gui : 789
gui : 789
gui : 789
abc : 120
The followibng gives o/p as
$ grep -n "gui : 789" file.txt | cut -f1 -d:
1
2
3
4
If there are N number of such gui : 789 , how to store the line numbers of the same ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use this awk 1 liner:
To process this inside a loop:
EDIT: These command will work for any number of matches in the file. To store output of above line numbers in an array:
later on process these array elements as: