2013-11-15 4 views
0

파일유닉스에서 파일 사이에 문자열을 추가하는 방법

AVAIL_CHECK_SECS=30
# we need at least one server
if [ -z "$1" ]; then
usage "Missing hostname parameter(s)"
fi

출력이 있어야 할 것입니다

AVAIL_CHECK_SECS=30
,
# we need at least one server
if [ -z "$1" ]; then


usage "Missing hostname parameter(s)"
fi 나는 2 줄이는 방식으로 작동 원격 서버

답변

0
sed -e '1a\ 
# cache a copy of the agent jar for pushing to remote servers' File 

에 밀어위한 # 캐시에게 에이전트 항아리의 사본을, 즉 사이에 선을 추가 할 줄 번호. /^AVAIL_CHECK_SECS/ 또는 1a/# we need/i으로 바꿀 수 있습니다. 줄을 배치해야하는 위치의 앞이나 뒤에있는 줄의 패턴을 일치 시키면됩니다.

0

당신이 할 수있는 awk 사용 :

awk 'NR==1 {$0=$0 "\n# cache a copy of the agent jar for pushing to remote servers"} 1' file 
AVAIL_CHECK_SECS=30 
# cache a copy of the agent jar for pushing to remote servers 
# we need at least one server 
if [ -z "$1" ]; then 
usage "Missing hostname parameter(s)" 
fi 
관련 문제