Reputation: 91
I have a output in a file and i want to parse the file line by line to just get the line with the "ip address(10.113.193.70)" and the "Version: 47.80.99.08" to the standard output. What would be the best way to parse using grep/awk or bash?
10.113.193.70
Executing (0,0,0,0,0,0,0,0,0,0):
==== product information ====
Product: e10
Package: default
Version: 47.80.99.08
Type: customer
Builder: symsm
Project: RAID
Upvotes: 2
Views: 2777
Reputation: 17614
all of awk
sed
grep
bash
will work
this is assuming that the line with the IP is on the start of the line,
and no other line starts with a digit.
Otherwise you can refine the IP pattern.
bash:
#!/usr/bin/env bash
while read -r
do [[ $REPLY =~ ^(Version|[[:digit:]]) ]] && echo "$REPLY"
done < file
grep:
$ grep "^\(Version\|[[:digit:]]\)" file
10.113.193.70
Version: 47.80.99.08
awk:
$ awk '$1 ~ /^(Version|[0-9])/ { print }' file
10.113.193.70
Version: 47.80.99.08
sed:
$ sed -n '/^\(Version\|[[:digit:]]\)/p' file
10.113.193.70
Version: 47.80.99.08
Upvotes: 5