The following Perl script (my.pl
) can read from either the file in the command line arguments or from standard input (STDIN):
while (<>) {
print($_);
}
perl my.pl
will read from standard input, while perl my.pl a.txt
will read from a.txt
. This is very handy.
Is there an equivalent in Bash?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…