Suppose I have a file.txt with the following lines :
hello myname1 is yellow.pcapng red festive myname33 is hddd.pcapng dfdf crude myname44 is hello.pcapng
Now my goal is to filter to the lines so it outputs to out.txt as follows :
myname1 yellow.pcapng myname33 hddd.pcapng myname44 hello.pcapng
Now I know that I can use :
grep -oh "\w*myname\w*" /tmp/file.txt > /tmp/out.txt grep -o '[^ ]\+g' /tmp/file.txt > /tmp/out.txt
to get the both respective parts of the expression individually. How do I combine these commands so that I get my desired output?