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