I'm having trouble executing a Perl script through the Unix shell using Perl's system command.I've had more complex regex commands I had to adjust accordingly to convert from Unix to Perl, and they're working fine, but I can't seem to figure out what's missing here.I've tested with Mobaxterm v7.1 and Putty 0.60.I have a file (file.txt):23445 dir1/dir2/dir321343 dir1/dir2/dir3/dir4/file.B254322 dir1/dir2/dir3/file3.P53223 dir1/dir2/dir3/dir4/dir523412 dir1/dir2/dir3/dir4/dir5/file5.xsd54166 dir1/dir2/file6.AB64544 dir1/dir2/fil7.ABEFrom this file I'm trying to grep only the lines with files (exclude directories: lines 1 and 4), and store them in a new file:system(grep '^.*\.[a-zA-Z0-9][a-zA-Z0-9]*\$' file.txt > file2.txt);file2.txt doesn't change from file.txt and still contains the directories.However, this command works through Unix shell (without the backslash before the $):grep '^.*\.[a-zA-Z0-9][a-zA-Z0-9]*$' file.txt > file2.txtfile2.txt output:21343 dir1/dir2/dir3/dir4/file.B254322 dir1/dir2/dir3/file3.P23412 dir1/dir2/dir3/dir4/dir5/file5.xsd54166 dir1/dir2/file6.AB64544 dir1/dir2/fil7.ABEI have to escape the $ character in the Perl system command of course so that Perl doesn't read it as an unknown string.  Other than that, what needs to be adjusted in the system command?
Regex works in shell but not through Perl script
shell script;grep;regular expression;perl;quoting
In double quotes, you need to backslash backslashes, i.e. double the backslash before the dot.system(grep '^.*\\.[a-zA-Z0-9][a-zA-Z0-9]*\$' file.txt > file2.txt);#                ^#                |#              Here.