문제

#!/bin/bash 
command1 |while read
do
set -- $REPLY
command2
done

I was browsing the net and I came across this piece of code. What does 'set -- $REPLY' do ?

도움이 되었습니까?

해결책

It splits down $REPLY into tokens and put them into $@ (arguments)

$REPLY is the implicit target for while read expression. But do remember that using while read with implicit target is a bash-ism and it's supported in e.g. ash (but supported in zsh). Better use while read REPLY

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top