开发者

perl linux command not working

开发者 https://www.devze.com 2023-02-12 16:40 出处:网络
cat t.incopt.02.20110221 | awk -F, \'{print $1}\' | sort | uniq got unque records but if i inserted into perl,
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开发者_C百科`;

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,


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;`


Try the following:

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

@FETCH_REQ_DETAILS = `$cmd`;

0

精彩评论

暂无评论...
验证码 换一张
取 消