#!/bin/bash
echo -e "What is your name:\c"
read name
echo $name
$ cat > myfile
This is great
<CTRL+D>
$ pg myfile
This is great
who | tee who.out 我们使用 who命令,结果输出到屏幕上,同时保存在文件who.out中
#! /bin/sh
if [ -f $1 ]; then
cat $1 |
while read cmd
do
c++filt $cmd
done
fi
# alert an error msg
function alert()
{
echo -en "\\033[40;31m" # set font color as red
echo -en "$*"
echo -en "\\033[0;39m" # restore font color as normal
}
function success()
{
echo -en "\\033[40;32m" # set font color as green
echo -en "$*"
echo -en "\\033[0;39m" # restore font color as normal
}
# run program and do not display the output
function run_quiet()
{
local cmd=$*
$cmd >/dev/null 2>&1
return $?
}
[root@hhb-kvm ~]# cat ./tst.sh
#!/bin/sh
function edit()
{
p=$1
eval $p=1045
}
x=100
px=x
echo $x
edit $px
echo $x