2015-02-05 1 views
3

bash 기록에 문제가 있습니다.greping 히스토리가 올바르게 작동하지 않으면! bang으로 내역 명령 실행

내가 역사를 history | grep forever으로 부르는 것을 가정 해 봅시다. 영원히 포함 된 모든 이전 명령은 해당 숫자와 함께 표시됩니다.

이러한 명령 중 하나를 해당 번호 (예 : !2121)로 실행하면 내역과 다른 명령이 호출되고 해당 번호와 연결된 명령이 호출되지 않습니다. 내가 뭘 잘못하고 있니?

greping하지 않고 기록을 호출하면 예상대로 뱅 실행이 작동합니다.

들으

무서운 예 :

... 
1742 forever stop 0 
1743 forever -o out.log -e err.log start -c nodemon hotnews.js 
1784 forever list 
1814 forever list 
2496 forever -o out.log -e err.log start -c nodemon hotnews.js 
2498 forever -o out.log -e err.log start -c nodemon hotnews.js 
2957 forever -o out.log -e err.log start -c nodemon hotnews.js 
3292 forever -o out.log -e err.log start -c nodemon hotnews.js 
3452 forever -o out.log -e err.log start -c nodemon hotnews.js 
3603 forever -o out.log -e err.log start -c nodemon hotnews.js 
3614 history | grep forever 
[~]$ !1784 
npm uninstall express-flash 
npm WARN uninstall not installed in /home/development/node_modules: "express-flash" 
[~]$ 

편집 :

내가 .bashrc에 내 역사의 속성을 변경 기억 :

# don't put duplicate lines or lines starting with space in the history. 
# See bash(1) for more options 
export HISTCONTROL=ignoreboth:erasedups 

# append to the history file, don't overwrite it 
shopt -s histappend 

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) 
export HISTSIZE=100000 
export HISTFILESIZE=100000 

# ignoriert einfache Befehle wie cd 
export HISTIGNORE='cd:ls:bg:fg:history' 

export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND" 

아마 어떻게 든 결함이 항목입니다 ?

+0

숫자가 '.bash_history' 파일의 명령에 해당합니까? – styvane

+0

예, 위의 예를보세요. – Subimago

+0

죄송합니다. 니가 옳았 어. history-command의 결과는 .bash_history (cat -n .bash_history)와 다른 숫자입니다. 어떻게 이럴 수있어? – Subimago

답변

0

아마도 당신은 .bash_history에 빈 줄이나 다른 바보 같은 것들이있을 것입니다. 버그를 찾으려면 다음을 시도해보십시오.

history | tr -d '[:blank:]' > foo 
cat -n .bash_history | tr -d '[:blank:] > bar 
diff foo bar 
+0

history-command의 출력이 .bash_history (cat -n .bash_history)와 다른 수입니다. 어떻게 이럴 수있어? .bash_history 파일이 history 명령의 기초라고 생각했습니다. – Subimago

+0

동일해야하지만, 히스에서 읽기가 빈 줄을 무시하면 (그리고 어쩌면 다른 것들). 그래서 숫자가 달라지기 시작합니다. – Nudin

관련 문제