xbox360dp
asked on
Perl Script - Remove row of data based on column value
Gurus,
I need a perl script that will delete a row or rows of data based a column value.
Example
File1.txt - Before
Data1|00|123
Data2|11|456
Data3|10|789
Example
File1.txt - After
Data2|11|456
Data3|10|789
So delete from file where column 2 equals "00"
Thanks!
I need a perl script that will delete a row or rows of data based a column value.
Example
File1.txt - Before
Data1|00|123
Data2|11|456
Data3|10|789
Example
File1.txt - After
Data2|11|456
Data3|10|789
So delete from file where column 2 equals "00"
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Data1|00|123
Data2|11|456
Data3|10|789
perl -F'\|' -i.bak -ane 'print "$F[0]|$F[1]|$F[2]" unless $F[1] =~ /^00$/' File1.txt
File1.txt - After
Data2|11|456
Data3|10|789
File1.txt.bak - Backup File
Data1|00|123
Data2|11|456
Data3|10|789