4 Şubat 2018 Pazar

bash kodlama - history built-in komutu

Giriş
Oturum (session) kapandıktan sonra komutlar şu dosyaya yazılır.
~/.bash_history
Aslında bash içinde iki tane history belleği vardır. Açıklaması şöyle
Your bash history consists of two "histories", not one. One of these histories is stored in a file - its size/depth is governed by the parameter HISTFILESIZE. The other history is cached in memory - its size is governed by the parameter HISTSIZE.
Komutlar önce session'daki belleğe yazılır. Eğer bu bellek yetmezse, taşan komutlar dosyaya yazılır. Açıklaması şöyle. Bu komut session history içindir. 
The reason for two histories is that one is associated with each shell session (HISTSIZE), while the other history is a file ~/.bash_history that is "permanent", and eventually receives the session histories when they overrun their max depth, or when the session is terminated. 
En Komutlar
En son 10 komutu görmek için şöyle yaparız.
history 10 > ~/Desktop/History.txt
-c seçeneği
session history listesini silmek içindir.
Örnek
Şöyle yaparız
$ history -cw
-d seçeneği
Belli bir satırı tarihçeden silmek için şöyle yaparız.
history -d ROW#
Diğer
Komut tarihçeye dahil olması istersek boşluk karakteri ile başlarız. Şöyle yaparız.
$ echo test
test
$ history | tail -n2
 3431  echo test
 3432  history | tail -n2
$ echo test2
test2
$ history | tail -n2
 3431  echo test
 3432  history | tail -n2
Boşluk karakteri ~/bash.rc dosyasında atanıyor.
HISTCONTROL=ignoreboth
Açıklaması şöyle.
HISTCONTROL
A colon-separated list of values controlling how commands are saved on the history list. If the list of values includes ignorespacelines which begin with a space character are not saved in the history list. A value of ignoredups causes lines matching the previous history entry to not be saved. A value of ignoreboth is shorthand for ignorespace and ignoredups.

Hiç yorum yok:

Yorum Gönder