shell编程 拿到标准输入

在shell编程中我们可以通过$1拿到参数 

如    ./myscript.sh   aaaa

这时  $1 就是  aaaa

 

 

但假如我们想拿到通道给我们的标准输入呢?

如    ls -l  |  ./myscript.sh   想拿到 ls -l 的输出呢

 

 

这时可以这样

while read inputline
do
  echo input  = $inputline 
done 
 

你可能感兴趣的:(shell编程)