Perl removing line match with pattern in column


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl removing line match with pattern in column
# 1  
Old 05-27-2015
Perl removing line match with pattern in column

Hi,

I have log like this:

Code:
"70","","0004573","6714191b","3607994989","fg985549","xnet","f121","0a888c03","1","150225231446","6","0","2","vm1","51000264","0","6738852681","0800","","","","82","","1","3","","2001","2","","","0","00400000","021b931f739668f47483ffff","","25f811","0","0","150225231452+0800","","0","200"
"70","","0001746","6714191b","2183481519","fg14191b","xnet","f121","0a881a1b","1","150225230952","300","17","13","vm1","51000265","0","6738606508","0800","","","5302166019927230","6","","0","30","","2001","13","150225231008+0800","150225231451+0800","283","00000000","067c0900030d4000030d40","","25f811","10246","3233","150225231452+0800","","0","200"
"70","","0001746","6714191b","2183481519","fg14191b","xnet","f121","0a881a1b","1","150225230952","300","17","13","vm1","51000265","0","6738606508","0800","","","5302166019927230","6","","1","30","","2001","3","150225230952+0800","150225231010+0800","18","00000000","067c0900030d4000030d40","","25f811","14857","3778","150225231452+0800","","0","120"
"70","","0001746","6714191b","2183481519","fg14191b","xnet","f121","0a881a1b","1","150225230952","300","17","13","vm1","51000265","0","6738606508","0800","","","5302166019927230","6","","2","30","","2001","2","150225231305+0800","150225231305+0800","0","00000000","067c0900030d4000030d40","","25f811","277","168","150225231452+0800","","0","130"
"70","","0286403","ca985504","1603569898","fg985549","xnet","f121","0ab8a6e8","1","150225230952","300","17","1215","vm1","51000266","0","6738973985","0800","","","","82","","0","3","","2001","1205","","","0","00000000","021b931f739668f474831078","","","0","0","150225231452+0800","","0","140"
"70","","0286403","ca985504","1603569898","fg985549","xnet","f121","0ab8a6e8","1","150225230952","300","17","1215","vm1","51000266","0","6738973985","0800","","","","82","","1","3","","2001","1214","","","0","00000000","021b931f739668f474831078","","","0","0","150225231452+0800","","0","200"
"70","","0286403","ca985504","1603569898","fg985549","xnet","f121","0ab8a6e8","1","150225230952","300","17","1215","vm1","51000266","0","6738973985","0800","","","","82","","2","3","","2001","1214","","","0","00000000","021b931f739668f474831078","","","0","0","150225231452+0800","","0","8"
"70","","0286403","ca985504","1603569898","fg985549","xnet","f121","0ab8a6e8","1","150225230952","300","17","1215","vm1","51000266","0","6738973985","0800","","","","82","","3","3","","2001","1001","","","0","00000000","021b931f739668f474831078","","","0","0","150225231452+0800","","0","3"
"70","","0673635","ca985504","1609982291","fg985549","xnet","f121","0ab808b4","1","150225230952","300","17","12","vm1","51000267","0","6738846732","0800","","","","82","","0","3","","2001","12","150225231025+0800","150225231426+0800","241","00000000","021b931f739668f474831078","","","1249","968","150225231452+0800","","0","200"
"70","","0673635","ca985504","1609982291","fg985549","xnet","f121","0ab808b4","1","150225230952","300","17","12","vm1","51000267","0","6738846732","0800","","","","82","","1","3","","2001","12","150225231429+0800","150225231433+0800","4","00000000","021b931f739668f474831078","","","4699","5049","150225231452+0800","","0","120"


The log is csv format. I want to remove column 37 and 38 that contains 0 value. if column 37 and 38 is 0 value will remove using perl

Anybody can help?

Thank you.
BR//
# 2  
Old 05-27-2015
Hello justbow,

I have a few to questions pose in response first:-
  • Is this homework/assignment? There are specific forums for these.
  • What have you tried so far?
  • What output/errors do you get?
  • What OS and version are you using?
  • What are your preferred tools? Is perl required by some other reason? Could we use C, shell, awk, etc.
  • What logical process have you considered? (to help steer us to follow what you are trying to achieve)
Most importantly, What have you tried so far?

There are probably many ways to achieve most tasks, so giving us an idea of your style and thoughts will help us guide you to an answer most suitable to you so you can adjust it to suit your needs in future.


We're all here to learn and getting the relevant information will help us all.


Kind regards,
Robin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

If pattern match in other column, modify column 3.

My command sed will modify everything in column 3 if i will use the command below. I want to search for a pattern then modify everything in column 3. sed -i 's/\|165\|/server1/g' file.txt Input: 01-31-2019 19:14:05|device|165|1548962040165|5c5348f9-0804-1111|file_attach|7271|587|smtp|... (6 Replies)
Discussion started by: invinzin21
6 Replies

2. Shell Programming and Scripting

awk to combine lines from line with pattern match to a line that ends in a pattern

I am trying to combine lines with these conditions: 1. First line starts with text of "libname VALUE db2 datasrc" where VALUE can be any text. 2. If condition1 is met then continue to combine lines through a line that ends with a semicolon. 3. Ignore case when matching patterns and remove any... (5 Replies)
Discussion started by: Wes Kem
5 Replies

3. Shell Programming and Scripting

Delete line by pattern match in column

file: 1|12322|tow| 5|23422|pow| 6|23423|cow| 3|34324|how| deletelines: 12322 23423 My command to delete line while read NUM do awk -F"\|" '$2 !~ /`"$NUM"`/' file >file.back mv file.back file done<deletelines (3 Replies)
Discussion started by: Roozo
3 Replies

4. Shell Programming and Scripting

Perl removing line match with pattern in column

Hi, I have log like this: ... (1 Reply)
Discussion started by: justbow
1 Replies

5. Shell Programming and Scripting

Match Pattern and print pattern and multiple lines into one line

Hello Experts , require help . See below output: File inputs ------------------------------------------ Server Host = mike id rl images allocated last updated density vimages expiration last read <------- STATUS ------->... (4 Replies)
Discussion started by: tigerhills
4 Replies

6. Shell Programming and Scripting

Rearrange or replace only the second line after pattern match or pattern match

Im using the command below , but thats not the output that i want. it only prints the odd and even numbers. awk '{if(NR%2){print $0 > "1"}else{print $0 > "2"}}' Im hoping for something like this file1: Text hi this is just a test text1 text2 text3 text4 text5 text6 Text hi... (2 Replies)
Discussion started by: invinzin21
2 Replies

7. Shell Programming and Scripting

Print only next pattern in a line after a pattern match

I have 2013-06-11 23:55:14 1Umexd-0004cm-IG <= user@domain.com I need sed/awk operation on this, so that it should print the very next pattern only after the the pattern mach <= ie only print user@domain.com (7 Replies)
Discussion started by: anil510
7 Replies

8. Shell Programming and Scripting

Adding Column Values Using Pattern Match

Hi All, I have a file with data as below: A,FILE1_MYFILE_20130309_1038,80,25.60 B,FILE1_MYFILE_20130309_1038,24290,18543.38 C,FILE1_dsc_dlk_MYFILE_20130309_1038,3,10.10 A,FILE2_MYFILE_20130310_1039,85,110.10 B,FILE2_MYFILE_20130310_1039,10,12.10... (10 Replies)
Discussion started by: angshuman
10 Replies

9. Shell Programming and Scripting

I need to know how to replace a line after a pattern match with an empty line using SED

Hi How Are you? I am doing fine! I need to go now? I will see you tomorrow! Basically I need to replace the entire line containing "doing" with a blank line: I need to the following output: Hi How Are you? I need to go now? I will see you tomorrow! Thanks in advance.... (1 Reply)
Discussion started by: sags007_99
1 Replies

10. Shell Programming and Scripting

pattern match and replace another pattern in same line

I have a pattern username:x:32005:32006::/usr/local/user:/bin/bash I need to match the line containing username and replace /bin/bash with /usr/local/my/bin/noshell So it becomes username:x:32005:32006::/usr/local/user:/usr/local/my/bin/noshell (7 Replies)
Discussion started by: anilcliff
7 Replies
Login or Register to Ask a Question