Reputation: 4904
My program output is as the following:
# myprogram list
val
val.dev
val.int
val.int.p1
val.int.p2
val.int.p3
val.int.p4
val.int.p5
val.dev.p6
I want to extract from the above output only strings under val.int.
so I want to add something to the command in order to get the following output:
# myprogram list|<something options>
p1
p2
p3
p4
p5
Is it possible to do it with awk
(or someting similar like sed
) in only one call of awk
?
Upvotes: 0
Views: 1024
Reputation: 195229
try this:
awk -F'val.int.' '$0=$2' file
file contains your data:
kent$ awk -F'val.int.' '$0=$2' file
p1
p2
p3
p4
p5
Upvotes: 1
Reputation: 532238
Yet another solution, this one involving grep
and Perl regular expressions:
$ myprogram list | grep -Po "(?<=val\.int\.).*"
Upvotes: 1