The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM



Thread: help with perl
View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #6 (permalink)  
Old 05-16-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
What's the point of using Perl if the one thing Perl can do really well is handled by a shell function?

Code:
#!/usr/bin/perl -n
if (m%<cd>(.*?)</cd>% { print "$1\n" }
Save that to a file and run it from a shell script which invokes it on each file in turn. Or just type this one-liner directly at the prompt.

Code:
perl -ne 'if (m%<cd>(.*?)</cd>%) { print "$1\n" }' *.txt >tmp.out
Reply With Quote