提交 49581efe 编写于 作者: S storypku

Script: user.bash_aliases add cat_line_from_line functionality

上级 701d3020
......@@ -2,6 +2,8 @@ export PS1="\[\e[31m\][\[\e[m\]\[\e[32m\]\u\[\e[m\]\[\e[33m\]@\[\e[m\]\[\e[35m\]
export PATH="$PATH:/apollo/scripts"
ulimit -c unlimited
if [[ -e "/apollo/scripts/apollo_base.sh" ]]; then
. /apollo/scripts/apollo_base.sh
fi
......@@ -18,4 +20,27 @@ function inc() {
fi
}
ulimit -c unlimited
function cat_file_from_line() {
local sed_cmd="$(command -v sed)"
if [[ -z "${sed_cmd}" ]]; then
error "sed not found in PATH"
return
fi
local filename_w_ln="$1"; shift;
local fname="${filename_w_ln%:*}"
local start_ln=1
if [[ "${filename_w_ln}" =~ :.* ]]; then
start_ln="${filename_w_ln##*:}"
elif [[ -z "$1" ]]; then
start_ln=1
else
start_ln="$1"; shift
fi
local line_cnt=9; # 10
if [[ -n "$1" ]]; then
line_cnt="$1"; shift
fi
# '10,33p' print line 10 to line 33
${sed_cmd} -n "${start_ln},+${line_cnt}p" "${fname}"
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册