Re: about matrix text editing
On Mon, Mar 10, 2003 at 04:02:47AM +0900, Youichi Mano wrote:
> I want to extract the lines of which the specified column is matched
> by command line programs(grep,cut,wc,...) not any script file.
>
> For example, there is tab separated matrix text like the following.
> and I want to extract of which the value of column number 2 is "111".
> ------------------------
> a 1957 111
> b 1902 222
> c 2001 111
> ------------------------
>
> i.e. the output will be
> ----------------
> a 1957 111
> c 2001 111
> ----------------
>
> Such a editing is easy in perl script but I cannot easily do that
> in command line.
Sure you can. Use perl's -e option.
perl -nle 'my @cols = split /\t/; print if $cols[2] eq "111"'
Cheers,
--
Colin Watson [cjwatson@flatline.org.uk]
Reply to: