Bash 将输出重定向到文件,同时使用cat和perl

Bash 将输出重定向到文件,同时使用cat和perl,bash,pipe,Bash,Pipe,我需要在一个文本文件中洗牌行,并将结果存储到一个新的文本文件中。 这是我使用的命令。但是,这会将混洗的行打印到控制台中,而不是输出文件中 cat infile | perl -MList::Util=shuffle -e 'srand 123; print shuffle(<>);' "$@"; > outfile catinfle | perl-MList::Util=shuffle-e'srand 123;打印shuffle();'"$@"; > 输出文件 删除最后一个;

我需要在一个文本文件中洗牌行,并将结果存储到一个新的文本文件中。 这是我使用的命令。但是,这会将混洗的行打印到控制台中,而不是输出文件中

cat infile | perl -MList::Util=shuffle -e 'srand 123; print shuffle(<>);' "$@"; > outfile
catinfle | perl-MList::Util=shuffle-e'srand 123;打印shuffle();'"$@"; > 输出文件

删除最后一个;让它工作

cat infile | perl -MList::Util=shuffle -e 'srand 123; print shuffle(<>);' "$@" > outfile
catinfle | perl-MList::Util=shuffle-e'srand 123;打印shuffle();'“$@”>输出文件

删除最后一个;让它工作

cat infile | perl -MList::Util=shuffle -e 'srand 123; print shuffle(<>);' "$@" > outfile
catinfle | perl-MList::Util=shuffle-e'srand 123;打印shuffle();'“$@”>输出文件

不受保护的分号是罪魁祸首

它只是停止当前命令并启动另一个空命令(创建一个空文件)

请注意,
perl
的额外的
“$@”
参数在这里是无用的,使用
cat
也是无用的。总之,你可以写:

perl -MList::Util=shuffle -e 'srand 123; print shuffle(<>);' infile > outfile
perl-MList::Util=shuffle-e'srand 123;打印shuffle();'填充>输出文件

不受保护的分号是罪魁祸首

它只是停止当前命令并启动另一个空命令(创建一个空文件)

请注意,
perl
的额外的
“$@”
参数在这里是无用的,使用
cat
也是无用的。总之,你可以写:

perl -MList::Util=shuffle -e 'srand 123; print shuffle(<>);' infile > outfile
perl-MList::Util=shuffle-e'srand 123;打印shuffle();'填充>输出文件