简体   繁体   中英

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,

我认为您只需要将命令括在反勾中并仅转义$

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM