in reply to Re^12: How do I use grep in a script
in thread How do I use grep in a script
The Name: is actually on a separate line in the text file ie.
STATUS Acct:142424 Disposition:9000 CANCEL Wait: 04/11/17 DEBTOR Name:LastName FirstName Ssn:123456789 Cbr: Ph:555.555.1212
So I need to somehow grab both the LastName and the 142424 and concatenate then into LastName_142424_2017.txt
But this does not take into account for the Name: search to be on another line and still keep ALL the text to be added to the new file.while (<$fh>){ next unless /\S/; # skip blank lines if (/Acct:(\d+)/){ $acct = $1; if (/Name:([^\s]+)/){ $acct = $1.'_'.$acct; } } push @{$data{$acct}},$_ if ($acct); }
Any suggestions on how I can accomplish this?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^14: How do I use grep in a script
by poj (Abbot) on Dec 28, 2017 at 15:57 UTC | |
by Flintlock (Novice) on Dec 28, 2017 at 16:06 UTC | |
by poj (Abbot) on Dec 28, 2017 at 16:17 UTC | |
by Flintlock (Novice) on Dec 28, 2017 at 16:34 UTC | |
by Flintlock (Novice) on Dec 29, 2017 at 14:40 UTC | |
|