I have a file that looks like this
ifconfig-push 123.456.789.000 123.456.789.111
Is it possible to use grep or awk to print only the first string that start with 123 and not the second 123?
I want the output to look like 123.456.789.000 and have multiple files where this first IP address is different but always starts with 123
>Solution :
By default awk will separate values in between spaces. This means that if each line of your input will be similar to the sample you provided, the 2nd field would be your target. You can also add pattern matching to check for 123
awk '/123/ {print $2}' inputfile.txt
/123/This is a check for 123 being on the line{print $2}This prints the second field on that line