#!/usr/bin/env bash for x in one two three four do echo number $x done output: number one number two number three number four
#!/usr/bin/env bash for myfile in /etc/r* do if [ -d "$myfile" ] then echo "$myfile (dir)" else echo "$myfile" fi done output: /etc/rc.d (dir) /etc/resolv.conf /etc/resolv.conf~ /etc/rpc
for x in /etc/r??? /var/lo* /home/drobbins/mystuff/* /tmp/${MYPATH}/* do cp $x /mnt/mydir done
for x in ../* mystuff/* do echo $x is a silly file done
for x in /var/log/* do echo `basename $x` is a file living in /var/log done
#!/usr/bin/env bash for thing in "$@" do echo you typed ${thing}. done output: $ allargs hello there you silly you typed hello. you typed there. you typed you. you typed silly.
Bir cevap yazın