Reputation: 319
I have a file with lines like below
17:59:49.987 - JobID 864563: Found 7 clips from SeqID 862753
17:59:49.987 - Processing Job 864562
17:59:50.003 - JobID 864561: Location 14695 applied clip data successfully. Updating OCAMT_GM_Sent
17:59:50.003 - Processing Job 864563
17:59:50.003 - JobID 864564
17:59:50.018 - JobID 864565
17:59:50.034 - Processing Job 864565
17:59:50.034 - JobID 864566
17:59:50.034 - JobID 864562
17:59:50.034 - JobID 864563
17:59:50.034 - Processing Job 864566
17:59:50.049 - JobID 864567
17:59:50.049 - JobID 864564
17:59:50.049 - Trying to send JobID 864566 to location 14623 at http://172.28.48.11/yb/ClipData.php. Retry count 0
17:59:50.049 - Processing Job 864567
I would like to capture certain strings so that its output file is something like below;
864563 17:59:49.987
864562 17:59:49.987
864561 17:59:50.003
864563 17:59:50.003
Since the the job id length is variable I am thinking of using regular expression \d+ and breaking the line in half using the word Job as a field separator but I am unsure if the following can be combined;
awk -F'Job*' '{print $1}'|awk '{print $1}'
awk -F'Job*' '{print $2}'
Upvotes: 2
Views: 159
Reputation: 1641
sed version:
sed -e 's/\([^ ]*\).*Job\(ID\)\? \([0-9]\+\).*/\3 \1/g'
or with extended regex as pointed out by @spasic:
sed -E 's/^(\S+).*Job(ID)? ([0-9]+).*/\3 \1/'
Upvotes: 3
Reputation: 1225
from your comments, i assume your are expecting something like this
using awk
awk -F'[ ]+-.*Job(ID)? |:[ ]+|[ ]+' '{print $2, $1}' file
Output:
864563 17:59:49.987
864562 17:59:49.987
864561 17:59:50.003
864563 17:59:50.003
864564 17:59:50.003
864565 17:59:50.018
864565 17:59:50.034
864566 17:59:50.034
864562 17:59:50.034
864563 17:59:50.034
864566 17:59:50.034
864567 17:59:50.049
864564 17:59:50.049
864566 17:59:50.049
864567 17:59:50.049
Upvotes: 3