Prev: Q. How do I get bash to respect my physical directory structure?
Next: quoting: $foo, $(foo), ${foo} ..
From: Rakesh Sharma on 8 Jan 2010 16:32 On Jan 8, 5:04 am, master44 <trp...(a)gmail.com> wrote: > I looking to write a bash shell script to parse a log file for the > first occurance of a date and then once that date is found, the > contents of the rest of the log file will be copied to a new file. > > Here is a simplified example of a log file (test.log) > > 2010-01-05 .... > 2010-01-06 .... > 2010-01-07 .... > 2010-01-07 .... > 2010-01-07 .... > > So for example I want to search for the first occurance of 2010-01-07 > and then copy the rest of the file to anther file (test2.log) > > So the new file (test2.log) would look like this: > > 2010-01-07 .... > 2010-01-07 .... > 2010-01-07 .... > > I am thinking this can be done with sed and I have tried the > following, but something is off... > > grep "2010-01-07|sed 's/^0//g'`" test.log|tail +2|head -1 > test2.log > > If anyone has done this before or has any ideas, I'd appreciate it! > > Thanks you can use the tool "sed" for this. sed -e ' /2010-01-07/!d :loop n bloop ' yourfile or, sed -e '/2010-01-07/,$!d' yourfile --Rakesh
First
|
Prev
|
Pages: 1 2 Prev: Q. How do I get bash to respect my physical directory structure? Next: quoting: $foo, $(foo), ${foo} .. |