Lilly,
Please forgive me, as some of my information may be out of date here, but...
First off, the default
grep program searches for simple strings - I think you want to use
egrep, or one of the
grep switches, which enables regular expressions.
Second, your regular expression is probably wrong. You say you want a "1" at the end of a line, which would be the regex
'1$'
; not the expression
' $1'
, which probably searches for the six character string consisting of four spaces, a dollar sign, and the numeral one.
Try:
- system "cat $source_path/s_${i}_${j}_0*testing.txt | egrep '1$' | head > $path/s_${i}_${j}.txt";
as a first cut. If the system complains about lack of
egrep, then you'll have to find the correct
grep command line switch(es).
Also, please try prototyping your system command from the command prompt - it'll give you a lot better feedback as to why things are (or are not) working. Once your prototype works as desired, then you can hoist it into your
Perl code.
Good Luck!