I'm looking for a simple way to utilize regex in a UNIX shell script where not every system will have perl extensions built into grep. What is really helpful about perl regex here is back/forward references which I haven't found a way to use effectively in sed. I've quickly come up with the following 1 liner:
tail --bytes=+K something.log| perl -e 'while (my $line = <STDIN>){if ($line =~ /$ARGV[0]/){print $line};}' 'my regex'
Q1. Is this a safe way to do things for perl? Q2. Should I just resort to writing the entire script in perl instead?