sh文件代码执行,含切换用户执行代码

1.代码添加到指定文件内容最后

echo "oracle   soft   nofile    1024">>etc/security/limits.conf

2.切换用户执行内容

su  - oracle -c  echo "
export EDITOR=vi
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_SID=orcl
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/12.2.0/db_1
export INVENTORY_LOCATION=/u01/oraInventory
export TNS_ADMIN=$ORACLE_HOME/network/admin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export NLS_LANG="American_america.zhs16gbk"
export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss'
export PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin:$PATH:$HOME/bin
umask 022">> .bash_profile

3,第1,2条可以放在SH文件一起执行,例如:

echo "oracle   soft   nofile    1024">>etc/security/limits.conf
su  - oracle -c  echo "
export EDITOR=vi
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_SID=orcl
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/12.2.0/db_1
export INVENTORY_LOCATION=/u01/oraInventory
export TNS_ADMIN=$ORACLE_HOME/network/admin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export NLS_LANG="American_america.zhs16gbk"
export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss'
export PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin:$PATH:$HOME/bin
umask 022">> .bash_profile

你可能感兴趣的:(.sh文件,shell,linux)