x=123 ; echo $x ; ls | { while read a ; do x=$a ; done ; echo $x;} de az 'ls |' helyett inkabb 'for i in *' es nem is all fenn a problema