Splitting unix output
I am trying to extract an address from a file.
grep keyword /path/to/file
how i find the line of code i want. The result is something like
var=http://address
Is there a way to only get the part immediately after the =
ie http://address
, given that the i greping for keyword is in var
and http://address
parts
+3
mskew
source
to share
3 answers
grep keyword /path/to/file | cut -d= -f2-
+4
Celada
source
to share
You can avoid unnecessary pipes:
awk -F= '/keyword/{print $2}' /path/to/file
+4
PP
source
to share
Just connect to cut
:
grep keyword /path/to/file | cut -d '=' -f 2
+2
chrisaycock
source
to share