[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: grep file



At 08:10 AM 4/14/2004, you wrote:
Not sure what mailing list I need to join to ask this question, so I will ask it here in the hopes of getting a good response. I am trying to get a specific line out of a file that changes size regularly using a shell script (#!/bin/sh). I use the following command:
/bin/cat $BACKUPLOG|grep "Downloaded: ">>$BACKUPLOG'2'
Of course $BACKUPLOG and $BACKUPLOG'2' refer to a couple of files. For some reason, it will pull out lines that are NOT part of the line that has "Downloaded: " in it. The other lines do have the word "Downloaded" in them, but not the colon and space after it. I was wondering if it would be easier to tell it just to cat the 2nd line from the end of the file. That is where the line is always at. Problem is, I do not know how to do this. I hope that someone has an idea on this and would be kind enough to send me the correction.

Ok, I found out how to do this. After emailing the question, I had an idea. What about using "/usr/bin/tail --lines=3". Well, that worked just fine. Don't know why I didn't think of that in the first place. I haven't gotten any replies yet from anybody, but I'll bet this is what everybody will tell me.


Sorry for the inconvenience, but Thanks to everybody who might still reply to this.

Steve




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]