|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 (permalink) |
|
Messages: n/a
Hébergeur: |
Hi,
I have a +200 kb log file from which I want to remove lines such as this one: 5950K ......... ......... ......... ......... ......... ......... 59% 5600K ......... ......... ......... ......... ......... ......... 60% 5650K ......... ......... ......... ......... ......... ......... 61% It's called wget-log. I'm not really good at linux bash shells so how do I remove those lines with "......... ......... ......... ........." ? I suppose I could do something like "cat wget-log | (some-command/grep?) > newfile" but there are probably better methods, including not creating a new file... Best regards Martin Jørgensen -- --------------------------------------------------------------------------- Home of Martin Jørgensen - http://www.martinjoergensen.dk |
|
|
|
#2 (permalink) |
|
Messages: n/a
Hébergeur: |
sed -i "/......... ......... ......... ......... ......... ......... /d"
urlog "Martin Jørgensen" <hotmail_spam@hotmail.com> ??????:1k43s3-k95.ln1@news.tdc.dk... > Hi, > > I have a +200 kb log file from which I want to remove lines such as this > one: > > 5950K ......... ......... ......... ......... ......... ......... 59% > 5600K ......... ......... ......... ......... ......... ......... 60% > 5650K ......... ......... ......... ......... ......... ......... 61% > > It's called wget-log. I'm not really good at linux bash shells so how do > I remove those lines with "......... ......... ......... ........." ? > > I suppose I could do something like "cat wget-log | > (some-command/grep?) > newfile" but there are probably better methods, > including not creating a new file... > > > Best regards > Martin Jørgensen > > -- > -------------------------------------------------------------------------- - > Home of Martin Jørgensen - http://www.martinjoergensen.dk |
|
|
|
#3 (permalink) |
|
Messages: n/a
Hébergeur: |
sorry,
you need escape . "yulangdong" <yulangdong@hotmail.com> дÈëÏûÏ¢ÐÂÎÅ :44eef415$1@news.starhub.net.sg... > sed -i "/......... ......... ......... ......... ......... ......... /d" > urlog > > "Martin Jørgensen" <hotmail_spam@hotmail.com> > ??????:1k43s3-k95.ln1@news.tdc.dk... > > Hi, > > > > I have a +200 kb log file from which I want to remove lines such as this > > one: > > > > 5950K ......... ......... ......... ......... ......... ......... 59% > > 5600K ......... ......... ......... ......... ......... ......... 60% > > 5650K ......... ......... ......... ......... ......... ......... 61% > > > > It's called wget-log. I'm not really good at linux bash shells so how do > > I remove those lines with "......... ......... ......... ........." ? > > > > I suppose I could do something like "cat wget-log | > > (some-command/grep?) > newfile" but there are probably better methods, > > including not creating a new file... > > > > > > Best regards > > Martin Jørgensen > > > > -- > > -------------------------------------------------------------------------- > - > > Home of Martin Jørgensen - http://www.martinjoergensen.dk > > |
|
|
|
#4 (permalink) |
|
Messages: n/a
Hébergeur: |
yulangdong wrote:
> "Martin Jørgensen" <hotmail_spam@hotmail.com> > ??????:1k43s3-k95.ln1@news.tdc.dk... > >>Hi, >> >>I have a +200 kb log file from which I want to remove lines such as this >>one: >> >>5950K ......... ......... ......... ......... ......... ......... 59% >>5600K ......... ......... ......... ......... ......... ......... 60% >>5650K ......... ......... ......... ......... ......... ......... 61% >> >>It's called wget-log. I'm not really good at linux bash shells so how do >>I remove those lines with "......... ......... ......... ........." ? >> >>I suppose I could do something like "cat wget-log | >>(some-command/grep?) > newfile" but there are probably better methods, >>including not creating a new file... >> >> >>Best regards >>Martin Jørgensen >> >>-- >>-------------------------------------------------------------------------- > > - > >>Home of Martin Jørgensen - http://www.martinjoergensen.dk > > sed -i "/......... ......... ......... ......... ......... ......... /d" > urlog > Top-posting fixed. Please don't top-post. A "." matches any character. Escape it ("\.") if you want to specifically only match a period. You also don't need to explicitly list every character if your sed supports RE intervals, e.g. to match 6 repetitions of 9 periods-then-a-space: sed '/\(\.\{9\} \)\{6\}/d' Regards, Ed. |
|
|
|
#5 (permalink) |
|
Messages: n/a
Hébergeur: |
Ed Morton <morton@lsupcaemnt.com> writes:
> yulangdong wrote: > >> sed -i "/......... ......... ......... ......... ......... ......... /d" >> urlog That worked fine, thanks. > Top-posting fixed. Please don't top-post. > > A "." matches any character. Escape it ("\.") if you want to > specifically only match a period. Only escape the first character, right? Or every one? I also don't really understand whether or not the citation marks " " are necessary? > You also don't need to explicitly list every character if your sed > supports RE intervals, e.g. to match 6 repetitions of 9 > periods-then-a-space: > > sed '/\(\.\{9\} \)\{6\}/d' That's too advanced for me... Can you break it up and explain that to me? Best regards Martin Jørgensen -- --------------------------------------------------------------------------- Home of Martin Jørgensen - http://www.martinjoergensen.dk |
|
|
|
#6 (permalink) |
|
Messages: n/a
Hébergeur: |
I would recommend learning perl and regular expressions. Try using the
following script: Script Name: unclog.pl (or whatever you want to call it) ======================= #!/usr/bin/perl -wn print if (!/^.*\.{9} .*$/); Make sure the permissions on unclog.pl are set to execute (i.e. 770) Then run the script as follows: unclog.pl wget-log > wget-unclog Hope this s. Art Ramos Martin Jørgensen wrote: > Hi, > > I have a +200 kb log file from which I want to remove lines such as this > one: > > 5950K ......... ......... ......... ......... ......... ......... 59% > 5600K ......... ......... ......... ......... ......... ......... 60% > 5650K ......... ......... ......... ......... ......... ......... 61% > > It's called wget-log. I'm not really good at linux bash shells so how do > I remove those lines with "......... ......... ......... ........." ? > > I suppose I could do something like "cat wget-log | > (some-command/grep?) > newfile" but there are probably better methods, > including not creating a new file... > > > Best regards > Martin Jørgensen > > -- > --------------------------------------------------------------------------- > Home of Martin Jørgensen - http://www.martinjoergensen.dk |
|
|
|
#7 (permalink) |
|
Messages: n/a
Hébergeur: |
First Lensman wrote:
> I would recommend learning perl and regular expressions. Try using the > following script: > > Script Name: unclog.pl (or whatever you want to call it) > ======================= > #!/usr/bin/perl -wn > > print if (!/^.*\.{9} .*$/); > > Make sure the permissions on unclog.pl are set to execute (i.e. 770) > > Then run the script as follows: > > unclog.pl wget-log > wget-unclog > why not issue it directly on the command line: perl -ne 'print if not /(? ?:\.){9} ){6}/' wget-log > wget-unclogXicheng |
|
|
|
#8 (permalink) |
|
Messages: n/a
Hébergeur: |
Martin Jørgensen wrote: > Hi, > > I have a +200 kb log file from which I want to remove lines such as this > one: > > 5950K ......... ......... ......... ......... ......... ......... 59% > 5600K ......... ......... ......... ......... ......... ......... 60% > 5650K ......... ......... ......... ......... ......... ......... 61% > > It's called wget-log. I'm not really good at linux bash shells so how do > I remove those lines with "......... ......... ......... ........." ? > > I suppose I could do something like "cat wget-log | > (some-command/grep?) > newfile" but there are probably better methods, > including not creating a new file... > > > Best regards > Martin Jørgensen > > -- > --------------------------------------------------------------------------- > Home of Martin Jørgensen - http://www.martinjoergensen.dk if you know Python, o = open("newfile","a") for lines in open("wget-log"): if not "......... ......... ......... ........." in lines: o.write(lines) o.close() |
|
![]() |
| Outils de la discussion | |
|
|