Advertisement
Malsasa

#bash Masalah Truncated History

Aug 26th, 2014
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 12.02 KB | None | 0 0
  1. #bash pada Tuesday, August 26, 2014 09:38 PM
  2. Mengenai cara mencegah bash history yang selalu terpotong
  3. =========================================================
  4.  
  5. [21:07:35] <Malsasa> I found my bash history always truncated into 500 lines again, after I open mode than 3 bash instance (3 Terminal Emulators concurrently). My .bashrc code for keeping the history is here http://paste.ubuntu.com/8145842/. I have specified histappend, make HISTSIZE big, using history -a -r, etc. but the history still truncated. How to make the bash history eternal, for all bash instance in any number Terminal window opened in one time? I need it, it is so important for me (tracking error, etc). Thanks.
  6. [21:07:36] <osse> the advantage of my method is that if the number of files is not equal to 55 files you will gzip a number of files unequal to 45, and if there are fewer than 10 files you get thousands of usage texts
  7. [21:07:57] <Riviera> Malsasa: I believe the FAQ addresses that.
  8. [21:08:04] <-- Naib (~j@fu/hw/naib) has quit (Quit: Nothing to see here)
  9. [21:08:07] <osse> !faq history > Malsasa
  10. [21:08:08] <greybot> Malsasa: http://mywiki.wooledge.org/BashFAQ/051 -- I want history-search just like in tcsh. How can I bind it to the up and down keys?
  11. [21:08:09] <Malsasa> Riviera: I will see it.
  12. [21:08:13] <osse> ooops
  13. [21:08:15] <osse> !faq history > lose
  14. [21:08:15] <greybot> lose: http://mywiki.wooledge.org/BashFAQ/051 -- I want history-search just like in tcsh. How can I bind it to the up and down keys?
  15. [21:08:16] <geirha> Malsasa: HISTSIZE wraps at 2^32 iirc
  16. [21:08:21] --> tandroid (~Adium@50-201-154-94-static.hfc.comcastbusiness.net) has joined #bash
  17. [21:08:23] <osse> !faq lose > Malsasa
  18. [21:08:24] <greybot> osse: No matches found at http://mywiki.wooledge.org/BashFAQ
  19. [21:08:24] <Aldaron> geirha: yeah, it's retarded because a retarded program needs to undestand it :)
  20. [21:08:53] <Aldaron> geirha: thanks for mentioning that, because I do get trouble when the month changes
  21. [21:08:53] <Riviera> Would of course be totally unretarded to have filenames that follow the limitations of a crappy shell.
  22. [21:09:04] <osse> !faq losing > Malsasa
  23. [21:09:05] <greybot> Malsasa: http://mywiki.wooledge.org/BashFAQ/088 -- How can I avoid losing any history lines?
  24. [21:09:07] <geirha> Malsasa: If you have bash 4.3, you can set them to -1 to get infinite history
  25. [21:09:15] --> Naib (~j@5751e858.skybroadband.com) has joined #bash
  26. [21:09:15] <-- Naib (~j@5751e858.skybroadband.com) has quit (Changing host)
  27. [21:09:15] --> Naib (~j@fu/hw/naib) has joined #bash
  28. [21:09:18] <-- Naib (~j@fu/hw/naib) has quit (Client Quit)
  29. [21:09:24] <geirha> on older versions, the highest number you can set is $((2**31 - 1))
  30. [21:09:42] <Malsasa> osse: I am going.
  31. [21:09:53] --> Naib (~j@5751e858.skybroadband.com) has joined #bash
  32. [21:09:53] <-- Naib (~j@5751e858.skybroadband.com) has quit (Changing host)
  33. [21:09:53] --> Naib (~j@fu/hw/naib) has joined #bash
  34. [21:10:18] <osse> $((2**32 - 1)) you mean?
  35. [21:10:41] <geirha> osse: I don't remember if it's signed or unsigned. Best go 31 to be on the safe side
  36. [21:10:58] <geirha> Malsasa: Also, I recommend changing HISTFILE as well. That avoids running bash --norc truncating it to 500 lines again
  37. [21:11:15] <geirha> HISTFILE=~/.bash_history.$HOSTNAME  for instance
  38. [21:11:18] <osse> geirha: isn't the max 64 bits or something? Not for HISTFILE, but for $(())
  39. [21:11:32] <osse> # echo $((2**50))
  40. [21:11:33] <shbot> osse: 1125899906842624
  41. [21:11:56] <geirha> osse: yes, but HISTSIZE uses 32 bit int internally
  42. [21:12:07] <osse> ah
  43. [21:12:17] --> jasondotstar (~jasondots@2001:420:2280:1310:942e:7355:7ad4:7387) has joined #bash
  44. [21:12:50] <geirha> (( HISTFILESIZE = HISTSIZE = 2**31 - 1 ))
  45. [21:13:04] <-- darkbasic (~quassel@niko.linuxsystems.it) has quit (Quit: No Ping reply in 180 seconds.)
  46. [21:13:14] <Malsasa> geirha: thank you. But my HISTFILE was HISTFILE=~/.bash_history. Is it okay?
  47. [21:13:26] --> darkbasic (~quassel@niko.linuxsystems.it) has joined #bash
  48. [21:13:45] <geirha> Malsasa: that's the default, so it won't guard against bash --norc
  49. [21:14:00] <Savemech> osse: geirha:ty guys now itsworks really fine, now i can sleep well http://i.imgur.com/nCShuOl.png
  50. [21:14:12] <Savemech> Riviera:
  51. [21:14:38] <geirha> heh
  52. [21:14:44] <lhunath> Malsasa: by guard he means, if you ever start a default shell, it will wipe your history clean on exit.
  53. [21:14:57] --> elkorn (~elkorn@188.121.21.132) has joined #bash
  54. [21:14:59] --> somerandomnick12 (~a@gatek.thls.bbc.co.uk) has joined #bash
  55. [21:15:06] --> f-a (~f-a@nl1x.mullvad.net) has joined #bash
  56. [21:15:12] <-- Whiskey (whiskey@31.44.232.185) has quit (Ping timeout: 272 seconds)
  57. [21:15:13] <Malsasa> geirha: ooooow. Okay. I will change it.
  58. [21:15:30] <Malsasa> lhunath: thank you.
  59. [21:15:43] <f-a> so, due to me battling with bash I have not a file called --exclude=speccy . How to remove this?
  60. [21:15:53] --> jottr (~jottr@unaffiliated/jottr) has joined #bash
  61. [21:15:54] <geirha> well, wipe it down to the 500 line default
  62. [21:15:56] <-- koderok (~koderok@14.141.153.182) has quit (Quit: koderok)
  63. [21:16:14] <kerframil> f-a: rm -- <filename>
  64. [21:16:53] <f-a> thanks, that worked
  65. [21:17:03] <-- somerandomnick12 (~a@gatek.thls.bbc.co.uk) has quit (Client Quit)
  66. [21:17:29] <Malsasa> geirha: lhunath: osse: thank you. I have changed my bash history file name on .bashrc. I wanna back here soon after seeing the result.
  67. [21:17:47] <_val_> f-a: in case you're interested rm ./--exclude=speccy   works too
  68. [21:18:06] <_val_> what the heck is a speccy?
  69. [21:18:11] <geirha> Malsasa: Don't forget to change the HISTSIZE and HISTFILESIZE values too
  70. [21:18:17] <f-a> a folder with, 'lo and behold, spectrum games
  71. [21:18:20] <f-a> a lot of them
  72. [21:18:27] <Malsasa> geirha: yes. I have specified big big size for them.
  73. [21:18:51] <geirha> Malsasa: make sure it does not exceed 2^31-1
  74. [21:18:57] <geirha> (which your original did)
  75. [21:19:05] <Malsasa> geirha: ow. Okay, okay. Now I understand.
  76. [21:19:38] --> aquinas_ (~aquinas_@unaffiliated/aquinas) has joined #bash
  77. [21:19:52] --> somerandomnick12 (~a@gatek.thls.bbc.co.uk) has joined #bash
  78. [21:20:54] --> lpax (~lpax@unaffiliated/lpax) has joined #bash
  79. [21:20:58] <Malsasa> geirha: OOT: is this channel have a log? I have googled just a few seconds ago.
  80. [21:21:00] <geirha> Malsasa: Oh and don't export variables like HISTCONTROL and PROMPT_COMMAND
  81. [21:21:16] --> fork (~fork@unaffiliated/milefork) has joined #bash
  82. [21:21:20] <geirha> no official logs
  83. [21:21:33] <-- kahen (~infenwe@0118200527.0.fullrate.dk) has quit (Ping timeout: 250 seconds)
  84. [21:22:00] <-- Aldaron (1000@nblzone-228-25.nblnetworks.fi) has left #bash
  85. [21:22:18] --> sqlnoob (~techgaun@113.199.170.206) has joined #bash
  86. [21:22:55] --> semeion (~semeion@unaffiliated/semeion) has joined #bash
  87. [21:23:05] --> oxhak (~OxHaK@ns330132.ip-37-59-37.eu) has joined #bash
  88. [21:23:47] --> fork|2 (~fork@unaffiliated/milefork) has joined #bash
  89. [21:24:06] <-- semeion (~semeion@unaffiliated/semeion) has quit (Client Quit)
  90. [21:25:24] --> dennisw (~dennis@128.42.164.155) has joined #bash
  91. [21:26:01] <-- fork (~fork@unaffiliated/milefork) has quit (Ping timeout: 245 seconds)
  92. [21:26:13] --> semeion (~semeion@unaffiliated/semeion) has joined #bash
  93. [21:27:51] --> ntz (~jdoe@static-84-42-228-122.net.upcbroadband.cz) has joined #bash
  94. [21:27:53] <ntz> hello
  95. [21:28:04] <-- f-a (~f-a@nl1x.mullvad.net) has left #bash ("bai")
  96. [21:28:21] <ntz> how am I supposed to check in bash if the perms are exactly 600 and owner $EUID ?
  97. [21:28:42] <ntz> i can realize many ugly ways with sed and so
  98. [21:28:50] <geirha> chmod 600 file && echo "permissions are right"
  99. [21:29:16] <ntz> I need to check if the file has already that perms
  100. [21:29:21] <-- TomyWork (~tomy@85.199.84.100) has quit (Ping timeout: 250 seconds)
  101. [21:29:23] <ntz> I don't want to touch that file ..
  102. [21:29:32] <Jetchisel> find?
  103. [21:29:42] <ntz> yeah, that's one of "nasty"ways
  104. [21:29:46] <capt_mercaptan> geirha: lol
  105. [21:29:54] <_val_> UsingFind has some xamples I think.
  106. [21:29:57] <ntz> but probably find is good
  107. [21:29:58] <capt_mercaptan> ntz: stat
  108. [21:29:59] <geirha> or stat(1) if your system has one
  109. [21:30:02] <_val_> s/xamples/examples.
  110. [21:30:08] --> Alex-SF (~Alex-SF@71.198.230.165) has joined #bash
  111. [21:30:29] --> ScriptFanix (vincent@Jedrik.DMZ.riquer.fr) has joined #bash
  112. [21:30:33] <-- PotatoGim^Home (~potatogim@211.115.242.166) has left #bash ("전 이만 갑니다.")
  113. [21:30:38] <geirha> The find would be something like  [[ $(find file -perm 600 -print) ]]
  114. [21:30:44] <-- dreamon (~dreamon@unaffiliated/dreamon) has quit (Ping timeout: 240 seconds)
  115. [21:30:46] --> Nirgali42 (~dmart@64.132.167.18) has joined #bash
  116. [21:31:12] <geirha> silly find doesn't have a useful exit status, so you're left with testing output
  117. [21:31:12] <capt_mercaptan> find would be easier than stat
  118. [21:31:38] --> avostrik (~avostrik@178-16-155-142.obit.ru) has joined #bash
  119. [21:31:53] <capt_mercaptan> with stat, you'd get the permissions as a string (preferably in octal) and then have to string-compare with "0600"
  120. [21:32:04] <geirha> [[ $(find file -user "$EUID" -perm 600 -print) ]]
  121. [21:32:20] --> ggherdov (sid11402@gateway/web/irccloud.com/x-zeadfhvhwvzcpqpa) has joined #bash
  122. [21:32:28] <-- danemacmillan (~danemacmi@modemcable206.143-37-24.static.videotron.ca) has quit (Quit: WeeChat 1.0)
  123. [21:32:31] <ntz> Jetchisel: find /tmp/foo -perm 0600 -uid $EUID || something_else()
  124. [21:32:38] --> danemacmillan (~danemacmi@modemcable206.143-37-24.static.videotron.ca) has joined #bash
  125. [21:32:40] <ntz> yes, thanks .. that's all-in-one and good
  126. [21:32:57] --> magyar (~magyar@76.21.119.81) has joined #bash
  127. [21:33:00] <geirha> ntz: no. find doesn't have a useful exit status
  128. [21:33:02] <_val_> ntz: did you read the above thing? Find has no exit status.
  129. [21:33:05] <-- magyar (~magyar@76.21.119.81) has quit (Changing host)
  130. [21:33:05] --> magyar (~magyar@unaffiliated/magyar) has joined #bash
  131. [21:33:06] <-- Dary (~Dary@111.161.114.122) has quit (Ping timeout: 245 seconds)
  132. [21:33:10] <lhunath> -exec + can control find's exit code.
  133. [21:33:13] <ntz> it works
  134. [21:33:24] <geirha> and -user is posix, -uid is not
  135. [21:33:26] <ntz> i tested it with changing perms and owner ..but thanks
  136. [21:33:39] <osse> _val_: *no* exit status? So if you run find and then echo $? the shell SIGSEGVs? :O:O:O
  137. [21:33:47] --> PotatoGim^Laptop (~potatogim@211.115.242.166) has joined #bash
  138. [21:34:00] --> gargola (quassel@nat/hp/x-rrpumapugqbxtcbp) has joined #bash
  139. [21:34:34] <-- PotatoGim^Laptop (~potatogim@211.115.242.166) has left #bash
  140. [21:34:42] <Malsasa> geirha: okay, thank you. I have changed it.
  141. [21:35:01] <lhunath> and although I can't find a reference for it in the spec, all finds I have return 1 when the file doesn't exist.
  142. [21:35:04] <ntz> geirha: I know that -user is posix .. doing it on solaris
  143. [21:35:09] <capt_mercaptan> Can I use bash to randomize the instruction pointer's contents?
  144. [21:35:20] <geirha> ntz: Well, it won't work with GNU find at least
  145. [21:35:21] <ggherdov> hi. Is there anything to "decolorize" outputs ? I have some scripts that where written with a TTY in mind, and output fancy colors all around. Now I am running them headless-ly (automatic testing and the like) and I fetch their stdout. Those color codes are really disturbing.
  146. [21:35:21] <ggherdov> Any program I can pipe that stuff into, to get rid of colors?
  147. [21:35:24] <-- mdih (~dvillamer@112.210.72.68) has quit (Ping timeout: 260 seconds)
  148. [21:35:26] <ntz> it does
  149. [21:35:26] <lhunath> the best reference is that find Idontexist doesn't "All path operands were traversed successfully."
  150. [21:35:38] <ntz> i tested it right now on linux and solaris .. works reasonably
  151. [21:35:54] <capt_mercaptan> ggherdov: a sed script can be used to remove codes
  152. [21:36:07] <geirha> # touch file; chmod 666 file; find ./file -uid 0 -perm 600; echo $?
  153. [21:36:09] <shbot> geirha: 0
  154. [21:36:22] <geirha> ^ returns success even though the file has mode 666
  155. [21:36:34] <lhunath> ggherdov: TERM=dumb ?
  156. [21:36:48] <capt_mercaptan> ggherdov: you'd have to be more specific about what codes you're actually getting, like, are they ANSI escapes or terminal control code
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement