1

I would like to erase or replace in data exactly this: ": 20.08.2015 "

sample of data:

: 20.08.2015 02:39:26 :  ''    0  1 
: 20.08.2015 02:39:26 :  ''    0  1 
: 20.08.2015 02:39:26 :  ''    0  1 
: 20.08.2015 02:39:26 :  ''    0  1 
: 20.08.2015 02:39:26 :  ''    0  1 
: 20.08.2015 02:39:26 :  ''    1  0 
: 20.08.2015 02:39:27 :  ''    1  0 
: 20.08.2015 02:39:27 :  ''    1  0 
: 20.08.2015 02:39:27 :  ''    0  1 
: 20.08.2015 02:39:27 :  ''    1  0 
: 20.08.2015 02:39:27 :  ''    0  1 
: 20.08.2015 02:39:27 :  ''    0  1 
: 20.08.2015 02:39:30 :  ''    1  0 
: 20.08.2015 02:39:30 :  ''    0  1 
: 20.08.2015 02:39:31 :  ''    1  0 

after replace it should be:

02:39:26 :  ''    0  1
02:39:26 :  ''    0  1
02:39:26 :  ''    0  1
02:39:26 :  ''    0  1
02:39:26 :  ''    0  1
02:39:26 :  ''    1  0
02:39:27 :  ''    1  0
02:39:27 :  ''    1  0
02:39:27 :  ''    0  1
02:39:27 :  ''    1  0
02:39:27 :  ''    0  1
02:39:27 :  ''    0  1
02:39:30 :  ''    1  0

In pspad I can do it with expression "^(.*?).([0-9]+? )" but in cmd it doesn't work.

I added escape char in front of special characters.

My try is: "sed -i "s/(.*?).([0-9]\+?\ )//g" file.log

What's wrong?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Branis
  • 15
  • 6

3 Answers3

0
sed -i 's/^: 20\.08\.2015 //' file.log

not sure -i works in gnuwin (normaly GNU is ok)

if the date value is not exactly 20.08.2015 but in same format

sed -i 's/^: [0-3][0-9]\.[01][0-9]\.[12][09][0-9]\{2\} //' file.log

don't forget that . is any char and not dot so escape it

NeronLeVelu
  • 9,908
  • 1
  • 23
  • 43
0

Try this:

sed -i 's/: [0-9]\{2\}\.[0-9]\{2\}\.[0-9]\{4\} //' file.log

The problem in your expression is the lazy matching (+?) on your digits...this is not supported by sed.

Community
  • 1
  • 1
Sam
  • 20,096
  • 2
  • 45
  • 71
0

so, guys u were close, this works for me:

sed -i "s/: [0-3][0-9]\.[01][0-9]\.[12][09][0-9]\{2\} //g" file.log

thank you!

Branis
  • 15
  • 6