problem with file content extraction

I need to extract some content of a file.
Example

file abc
vi abc
ooooooooo
bbbbbbbbb
vvv 1234 5
vvv 6789 3
xxxxxxxxxx
xxxxxxxxxx

i want to extract only the following content from file abc and store in another file say temp.
1234 5
6789 3

what should be my approach?

You could print only fields 2 and 3 when a line contains 3 fields..

awk 'NF==3{print $2,$3}' infile
1 Like

If the file structure is the same this would work:

perl -lne 'print $1 if($_ =~ /.*(\d{4}\s\d{1})/)' file1.txt | tee file2.txt
1234 5
6789 3

cat file2.txt
1234 5
6789 3