I have few text files that has some key words. I have to select few lines from those files and parse it. Below is a sample file. I have to grep for "Customer" and get the line from the file.
13 Sun Sep 9 12:14:38 2012 : [P] Reproducer has the 167 number
13 Sun Sep 9 12:14:38 2012 : [P] Customer has the 12.14.19.9
13 Sun Sep 9 12:14:38 2012 : [P] Customer has the 12.14.89.9
13 Sun Sep 9 12:14:38 2012 : [P] Reproducer has the 170 number
13 Sun Sep 9 12:14:38 2012 : [P] Customer has the 12.4.89.16
I have to select only the lines that has Customer and have to parse it to get only the Timestamp (12:14:38) and the Number 12.14.19.9. I have to do this for multiple files. All the file has the same structure of the log. I have done this using the oneliner like below
grep Customer Neigh.log | cut -d " " -f 5- | cut -d ":" -f 1-4 | cut -d " " -f 1,8
But I need to do this inside a shell script. How can I do this. Can anyone help?
Thanks