-1

I have a command line argument that I need to convert into a shell script. Can someone explain me how to this?

If it is something simple like below, also, how to take care of lower and upper cases here?

cat * |perl -ne '{chomp; print "$_\n" if ($_=~ /MAR-|-MAR/|/JAN-|-JAN/|/FEB-|-FEB/|/APR-|-APR/|/MAY-|-MAY/|/JUN-|-JUN/|/JUL-|-JUL/|/AUG-|-AUG/|/SEPT-|-SEPT/|/OCT-|-OCT/|/NOV-|-NOV/|/DEC-|-DEC/|/dec-|-dec/|/Aug-|-Aug/|/Jan-|-Jan/|/Sept-|-Sept/)|/Feb-|-Feb/|/Mar-|-Mar/|/Apr-|-Apr/|/May-|-May/|/Jun-|-Jun/|/Jul-|-Jul/|/Oct-|-Oct/|/Nov-|-Nov/}'|more

Cœur
  • 37,241
  • 25
  • 195
  • 267
Rn408
  • 1
  • It looks like you have two separate topics here. Can you split them into separate questions? – AKHolland Jul 23 '14 at 15:16
  • 1
    You never have to use `cat` to feed input to Perl: Just put your arguments after the code: `perl -e'code here' *`. Although with a glob like `*` you would likely have to do some sanity checks to avoid processing directories and such. – TLP Jul 23 '14 at 16:00
  • 2
    Also, your regex has a grievous error: `/` is a meta character inside your regex, and you have not escaped it. Normally, you would get an error like `Search pattern not terminated`, but you have actually terminated yours by accident. This: `$_=~ /MAR-|-MAR/|/JAN-|-JAN/` means this: `$_ =~ m/MAR-|-MAR/ | $_ =~ /JAN-|-JAN/` -- two expressions with the `|` [bitwise OR operator.](http://perldoc.perl.org/perlop.html#Bitwise-Or-and-Exclusive-Or). – TLP Jul 23 '14 at 16:11

1 Answers1

1

To make your test case insensitive, add i. Example:

 if ($something =~ /re/i) {
konsolebox
  • 72,135
  • 12
  • 99
  • 105