I've never had occaison to run into that behavior -- very handy thing to be aware of though! I just had a few TMTOWTDI comments:
This is still easy with
grep if you know how to generate the tab character:
grep -Hn '<TAB>' *
Where "<TAB>" represents a tab character. To type the tab, first hit ctrl-v, then hit TAB -- that should insert an actual tab character. (note it probably won't copy/paste correctly, so be careful if you're copying the grep command from a notes file or something)
Also,
cat can be useful here as well (-n shows line numbers, -T shows TABs as "^I"):
cat -nT /tmp/foo | grep '\^I'
Couple alternative perl ways:
perl -lne 'print "$ARGV:$.:$_" if /\t/; close ARGV if eof' *
Identical to yours except i believe that the
... } continue { ... } { construct is unnecessary here and confusing at first glance until the reader remembers (if they know) that this is inserted (because of the -n) in a
while (<>) { ... } loop.
Since the original problem is that the line numbers increase accross ARGV files, this, while simple, isn't sufficient (works for only a single file) ...
perl -ne 'print "$ARGV:$.:$_" if /\t/' /tmp/foo
... so Yet Another Alternative :) would be to just wrap that in a shell (e.g. bash here) loop:
for f in * ; do perl -ne 'print "$ARGV:$.:$_" if /\t/' $f; done
(more awkward/more steps, but potentially useful in certains cases)
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.