Chinaunix
标题:
如何将一段shell语句重新添加到另外一个的shell里
[打印本页]
作者:
Iceecream
时间:
2015-02-05 14:31
标题:
如何将一段shell语句重新添加到另外一个的shell里
管理有许多台台主机,每台机器需要将下面的shell添加到/etc/profile里面
USER_IP=`who -u am i|awk '{print $NF}'|sed -e 's/[()]//g'`
if [ "$USER_IP" = "" ]
then
USER_IP=`hostname`
fi
要写一个shell来自动添加,该如何写呢,不管是echo,还是here document 都会输出类似下面的结果出来
USER_IP=192.168.1.2
if [ "" = "" ]
如何将原有的文本输出来呢。不会要一个个的转义吧,那转义的话岂不要死人了。
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2