Bharanikumar
Bharanikumar

Reputation: 25733

perl linux command not working

cat t.incopt.02.20110221 | awk -F, '{print $1}' | sort | uniq

got unque records

but if i inserted into perl,

@FETCH_REQ_DETAILS = `cat t.incopt.02.20110221 | awk -F\, '{print $1}' \| sort \| uniq`;

if i print the above array vari, i getting entire file content, i guess the linux command not working correctly when i use inside perl,

Upvotes: 0

Views: 462

Answers (2)

Krishna
Krishna

Reputation: 1861

I think you just need to enclose the command in back tick and escape only the $

@FETCH_REQ_DETAILS = `cat t.incopt.02.20110221 | awk -F, '{print \$1}' | sort | uniq;`

Upvotes: 4

qbert220
qbert220

Reputation: 11556

Try the following:

my $cmd='cat t.incopt.02.20110221 | awk -F, \'{print $1}\' | sort | uniq';

@FETCH_REQ_DETAILS = `$cmd`;

Upvotes: 1

Related Questions