[beyes@localhost shell]$ exec ./salutation.sh
Hello
The program /home/beyes/shell/salutation.sh is now running
The second parameter was
The first parameter was
The parameter list was
The user's home directory is /home/beyes
Please enter a new greeting
hi
hi
The script is now complete
[root@localhost Desktop]# //到这里,脚本执行完毕,返回到 root
#!/bin/bash
exec echo "hello world"
echo "display?"
root
beyes
love
duoduo
#!/bin/bash
#file_exec
exec 0<name.txt
read line1
read line2
read line3
read line4
read line5
read line6
read line7
echo $line1
echo $line2
echo $line3
echo $line4
echo $line5
echo $line6
echo $line7
[beyes@localhost shell]$ ./file_exec.sh
root
beyes
love
duoduo
#!/bin/sh
exec 1>testout.txt
echo "test line 1"
echo "test line 2"
echo "test line 3"
[root@centos shell]# cat testout.txt
test line 1
test line 2
test line 3
#!/bin/sh
exec 4<&0 0<name.txt
read line1
read line2
exec 0<&4
echo $line1
echo $line2
[beyes@localhost shell]$ ./file_exec.sh
root
beyes
欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) | Powered by Discuz! X3.2 |