如何获取当前的终端名称?
我的意思ps
是TTY列中显示的名称,例如:
root@dor-desktop:/home/dor/Documents/LAMP_setup/webs_install/do/install# ps aux | egrep 'mysql|(^USER)'
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
dor 2238 0.2 1.9 448052 79796 ? S 17:27 0:17 gedit /home/dor/Documents/LAMP_setup/webs_install/do/install/mysql.install /home/dor/Documents/LAMP_setup/webs_install/do/install/mysql.setup
root 4975 0.1 0.5 324984 22876 ? S 18:12 0:04 gedit /usr/local/mysql/bin/mysqld_safe
root 8160 0.0 0.0 4108 664 pts/2 S 19:08 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --skip-networking --skip-grant-tables --user=mysql --basedir=/usr/local/mysql --ledir=/usr/local/mysql/libexec
mysql 8279 0.0 0.4 146552 19032 pts/2 Sl 19:08 0:00 /usr/local/mysql/libexec/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/var --user=mysql --skip-networking --skip-grant-tables --log-error=/usr/local/mysql/var/dor-desktop.err --pid-file=/usr/local/mysql/var/dor-desktop.pid --socket=/usr/local/mysql/mysql.sock --port=3306
root 8342 0.0 0.0 7632 1024 pts/2 R+ 19:14 0:00 egrep --color=auto mysql|(^USER)
在上面的示例中,我需要获取pts/2
可能是执行这些命令的当前终端的名称。
相关:unix.stackexchange.com/questions/270272/...
—
西罗桑蒂利新疆改造中心法轮功六四事件