1 |
On 05/12/18 00:09, Paul Colquhoun wrote: |
2 |
> On Saturday, 12 May 2018 12:05:47 PM AEST Paul Colquhoun wrote: |
3 |
>> You can add an alternate regular expression that matches the blank lines, |
4 |
>> but the '-o' switch will still stop that match from being printed as it is |
5 |
>> an 'empty' match. The trick is to modify the data on the fly to add a space |
6 |
>> to the empty lines. I have also added the '-E' switch to make the regular |
7 |
>> expression easier. |
8 |
>> |
9 |
>> sed -e 's/^$/ /' YOUR_DATA_FILE | grep -o -E '([0-9]{4}|^[[:space:]]*$)' |
10 |
> |
11 |
> |
12 |
> If there is no other type of data in the file, just "lines with dates" & "blank |
13 |
> lines", then it can be done with just the 'sed' command on it's own: |
14 |
> |
15 |
> sed -e 's/.*\([0-9][0-9][0-9][0-9]\).*/\1/' YOUR_DATA_FILE |
16 |
> |
17 |
> |
18 |
|
19 |
Thanks to everyone for the replies. Yes, the data is only lines with |
20 |
mangled dates and spaces, and come to think of it, I was using sed the |
21 |
first go-around. |
22 |
|
23 |
Now that I'm more awake hopefully this process will go a bit easier. |
24 |
|
25 |
Thanks again everyone. |
26 |
|
27 |
Dan |