Link to home
Start Free TrialLog in
Avatar of davidw88
davidw88

asked on

How to write this shell script

Hi experts,

I have many files in following format

22  cpv 88  99  cpithisis
33  cpi 90  22  hecpvto
11  cpi ee  pp  timecpi
10  cpv 3e  79  shecpvcomes


The 2nd column is either "cpv" or "cpi". Each line has 5 columns and columns are "\t" seperated. Now I want to use shell script to split those lines of "cpv" to one file and "cpi" to another file.

I use following script but it is not correct. Can anybody help me to correct it?

Thanks so much.

cat *cpv_cpi*.txt | awk '{if ($2=="cpv") print $0}' | gzip > aa.txt

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of cyberstalker
cyberstalker

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of davidw88
davidw88

ASKER

Great. Thanks cyberstalker!