filesystems - awk part string compare -
i trying extract part of string using bash or awk.
i think can solve problem using read or awk.
my input_file below
cat ./input_file in_size=1 # out_size=2
so,
out_size=$(awk '{if($2=="out_size=2"){ blabla ; print output}' ./input_file)
i don't know how solve problem.
and, how can set multiple field separator fs empty space , tab.
there example like
fs='[/=]'
how can use 4 fs / = " " "\t" ??
thanks in advance.
use posix-style character class [:blank:]
includes horizontal whitespace characters.
awk -f '=|[[:blank:]]+' '{ (i=1; i<nf; i++) { if ($i == "out_size") { print $(i+1) exit } } }' filename
unless know it's 2nd word:
awk -f '=|[[:blank:]]+' '$2 == "out_size" {print $3; exit}' filename
Comments
Post a Comment