export PS2="continue->"
cat ps4.sh
export PS4='$0.$LINENO+ '
set -x
echo "PS4 demo script"
ls -l /etc/ | wc -l
du -sh ~
ramesh@dev-db ~> ./ps4.sh
../ps4.sh.3+ echo 'PS4 demo script'
PS4 demo script
../ps4.sh.4+ ls -l /etc/
In the PS1 environment variable, you can directly execute any Linux
command, by specifying in the format $(linux_command). In the following
example, the command $(date) is executed to display the current time inside
the prompt.
ramesh@dev-db ~> export PS1="\u@\h [\$(date
+%k:%m:%S)]>
本文介绍了一个简单的 PS4 shell 脚本示例,演示了如何设置和使用 PS4 环境变量来显示命令执行的详细信息。此外还展示了如何通过 PS1 环境变量直接执行 Linux 命令,并将当前时间整合到提示符中。
224

被折叠的 条评论
为什么被折叠?



