8 Star 20 Fork 5

hotmocha / minitalk

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
fn 836 Bytes
一键复制 编辑 原始数据 按行查看 历史
hotmocha 提交于 2016-02-02 14:18 . add some shell
mypath="$HOME/tmp/tmpfj"
line=""
if [ $# -ge 1 ]
then
line=$1
else
line=1
fi
current_pid=$$
parent_id="-1"
if [ $# -ge 2 ] #第二个参数传递指定文件号
then
parent_id=$2
else
parent_id=$(ps -o pid,ppid,comm | \
grep $current_pid | \
awk -v current_pid_var=$current_pid '$1==current_pid_var{print $2}')
fi
if [ ! -f "$mypath/$parent_id" ]
then
echo "请先用fu命令"
exit -1
fi
if [ $line -eq 0 ]
then
line=$(awk 'END{print FNR}' "$mypath/$parent_id")
echo $line
fi
result=$(awk -v li=$line 'BEGIN{FS=":"; count=0} NR==li{print $2 " " $3}' "$mypath/$parent_id")
p=""
l=""
count=0
for i in $result;
do
[ $count -eq 0 ] && p=$i;
[ $count -eq 1 ] && l=$i;
count=$((count + 1))
done;
echo "$p":"$1"
vi "+$l" "$p"
C
1
https://gitee.com/hotmocha/minitalk.git
git@gitee.com:hotmocha/minitalk.git
hotmocha
minitalk
minitalk
master

搜索帮助