Here is a sed
solution:
$ echo ':29.06.2019 23:03:17' | sed 's/^://'
29.06.2019 23:03:17
What the command sed 's/^://'
is doing is substitute s
the colon character :
from the beginning ^
of each line with the empty string //
.
Here is a tricky awk
solution, where we changing the field separator to ^:
, described above, and output the second field (of each line):
$ echo ':29.06.2019 23:03:17' | awk -F'^:' '{print $2}'
29.06.2019 23:03:17
The task could be accomplished also with grep
(explanation), probably this could be the fastest solution for large amount of data:
$ echo 'Logfile started :29.06.2019 23:03:17' | grep -Po '^Logfile started :\K.*'
29.06.2019 23:03:17
Or process the file directly by the following command, where the limitation ^
is removed:
grep -Po 'Logfile started :\K.*' process.log
The above could be achieved also by sed
and capture groups ()->\1
:
sed -nr 's/^.*Logfile started :(.*)$/\1/p' process.log
Where the expression ^.*<something>.*$
will match the whole line, that contains <something>
. The command s/old/new/
will substitute this line by the content of the first capture group (the expression in the brackets could be more concrete). The option -r
enables the extended regular expressions. The option -n
will suppress the normal output of sed
and finally the command p
will print the matches.