awk pattern search and put in a file

hi

I am doing a task that is i have to search for multiple pattern from a file's 9 th column and then redirect it to a new file

awk -F, 'BEGIN {OSF=","} { if ($9 == "OTF") print $0}' test1.tsv > test.tsv

and the patterns are OST. ODI,MIN LIKE OTF

Bit not getting the desired output
Please advise me

Thanks
Pranab

gawk  '$9~/^(OTF|SPI)$/'  file

your problem is in spelling

BEGIN {OSF=","}  >>> OSF is wrong it has to be BEGIN{OFS="," }

:D:D:D

After changing it to OSF TO OFS STILL NOT GETTING THE RESULT

THANKS

---------- Post updated at 04:37 PM ---------- Previous update was at 04:36 PM ----------

not getting the result

what is the i/p and the what is your desired o/p...put some data.

i am havinga file. In that file in 9th column i have to serch for patterns

OTC-SPI
OTC-SSP and so on

I and redirect the complete line to a new file

this is my desire

what is the o/p of cat file?

its like

1 ab gbh bnh bnhg hjh ghyh uio OTF gjgk jhkj
2 cv hjkj nlkl nknkn knk kkp kpkp SPI jhlk jl;kj

Please serch in the 9 th column OTF or SPI if persent then redirect the complete row to a new file

its like

1 ab gbh bnh bnhg hjh ghyh uio OTF gjgk jhkj
2 cv hjkj nlkl nknkn knk kkp kpkp SPI jhlk jl;kj

Please serch in the 9 th column OTF or SPI if persent then redirect the complete row to a new file

Hi Pranabrana,

cat file | awk ' { if ($9 == "OTF" || $9 == "SPI" ) print $0 }' > file1

Hope this will help you.

-Vijay.

Hey it Works !!!!:b: Thak you very very very much

Pranba Rana:D:o:)

---------- Post updated at 07:35 PM ---------- Previous update was at 07:33 PM ----------

Thanks it works.

:b::b::b::o:p;)