That line comes from a CSV producer. Is it possible to ask (them) to add a field that *only* has the source file?
- What if the file name becomes a URI?
- What if the file name will contain spaces?
- What if the comment changes?
- What if the file name will contain special characters like " or ,, that are totally valid in file names?
- What if the file name is case(in)sensitive?
- What if the path becomes relative or starts with a drive letter?
Assuming the line comes out the file named export.csv, you could try an overly safe approach like this:
$ cat export.csv
3,"2014-02-19 14:29:05","Extracted 1 Unfulfilled Reconciliation record
+s into /opt/mysql/backup/recon/201312/input/UNFULFILLED_RECONCILIATIO
+N_20130225.CSV","URECONCILIATION"
$ perl -MText::CSV_XS=csv -wE'for(@{csv(in=>"export.csv")}){say for ma
+p{s/.* into //i;$_}grep/\.csv/i=>@$_}'
/opt/mysql/backup/recon/201312/input/UNFULFILLED_RECONCILIATION_201302
+25.CSV
$
Requires Text::CSV_XS-1.04, but it is a one-liner now.
Enjoy, Have FUN! H.Merijn
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.