I have file on which I do grep on "/tmp/data" then I get 5 lines as
dir Path: /tmp/data/20162343134
Starting to listen on ports logging:
--
Moving results files from local storage: /tmp/resultsFiles/20162343134/*.gz to NFS: /data/temp/20162343134/outgoing
from above got to get 1st line dir Path: /tmp/data/20162343134
It would be interesting to see what grep command produced those four lines of output. And, if you think there are five lines there, it would be nice if you also showed us the other line.
But, depending on the options and operands you fed to grep to get that output, it would seem that unless other lines in /tmp/data contain the string Path: , you could get what you want just by using:
Being in the mind-reading business for so long i used the "applied conjecture"-method (also called "wild guessing procedure") and found out what you more or less probably want perhaps to be eventually done:
You have a file and filter some lines with a grep -statement. The filter matches several lines and you want only the first oneof these matches. (If this is not the case: don't bother telling us - we are all psychics.)
If so: you can either pipe that through the head -utility:
There aren't any double quotes in the input, and if the data we have been shown is the result of an earlier grep command, there is no reason to believe that the 1st line in the grep output was the 1st line in the original file. And, the request was for the entire line; not just the last field. So, if you want to do this with awk , shouldn't it just be: