386 reputation
16
bio website
location
age
visits member for 1 year, 11 months
seen Dec 15 at 17:38

Dec
9
comment What is the difference between “>” and “>>”?
In addition to the nice answer below, please see the 2nd (and most upvoted) answer on stackoverflow.com/a/984761/1841533 : using >> to write to a file (ex: a log) also has the nice side effect to not have "Nul" chars appear at the beginning of saif file if the file is truncated while the process still write to it! (ex: during log file rotation). Because "foo > file" doesn't seek, it doesn't notice the size change and still points further than the beginning, ad the OS fills with Nul. foo >>file seeks and therefore points to the new position (the beginning).
Dec
9
comment What is the difference between “>” and “>>”?
found what I meant: In addition to this nice answer, please see the 2nd (and most upvoted) answer on stackoverflow.com/a/984761/1841533 : using >> to write to a file (ex: a log) also has the nice side effect to not have "Nul" chars appear at the beginning of saif file if the file is truncated while the process still write to it! (ex: during log file rotation). Because "foo > file" doesn't seek, it doesn't notice the size change and still points further than the beginning, ad the OS fills with Nul. foo >>file seeks and therefore points to the new position (the beginning).
Oct
20
comment What is use of command: `command`?
+1 for a great pedagocical way to answer. However, I'd suggest to say that command something bypasses both function AND alias named something, whereas \something would just bypass the alias something but would execute the function. To my knowledge, there is no way to just bypass a function without bypassing also an alias named the same way. (Your answer says "it bypass the function (...) and go straignt to either builtins or your path" but doesn't mention explicitely it bypasses also aliases, which the OP (or maybe another person) may still need to see explictely written to "grok" it)
Sep
17
comment How can I run original command that aliased with same name?
additional precisions in bash : command something bypasses both alias AND function named something. \\something, 'something' and "something" only bypasses alias named something (if a function exist, it will then be called). (alias precede function if both exist and none are bypassed)
Sep
5
comment Remove the first part of a string using sed
+1. didn't see your answer, I'll remove my comment on OP's ^^
Aug
27
comment What are the advantages and disadvantages of mounting various directories on separate partitions?
+1, this answer covers a lot of good points! (this answer should be on top)
Aug
27
comment What are the advantages and disadvantages of mounting various directories on separate partitions?
+1 for a good list. But for 4. : Even with a separate partition, filling up /tmp could "stop the rest of the system", at least any other processes that needs to create/modify files in /tmp (and there are many, many of them). In most cases, that whole list is to ensure you can reboot to fix the filled partition, as the system critical one will still not be filled up (on that note, having a separate /boot is a good idea in most cases for this very purpose: / could be filled up)
Aug
14
comment What is the difference between Ctrl-z and Ctrl-c in the shell?
In case there are several jobs suspended or in the background : "jobs" list them, and "fg %n" or "bg %n" or even "kill %n" to put job %n in foreground, background, or kill it.
Jul
4
comment Bash Script: catching errors in a block of statements
you may have also to : set -o errtrace at the top-level of the script, if you also want that script's functions to call that trap in case of errors (otherwise, inside functions, that trap would not be called)
Jul
3
comment Remove letters and dots from all lines
$ time sleep 61 outputs: real 1m1.046s (ie, you don't want to get rid of the minutes... and you need sometimes to have leading zeroes (here, 1s is "1" and not "01"))
Jun
20
comment How to both display a command line's output on console and save the output into a text file?
@Dan: script doesn't need the -c "something ...": if will then drop you to a shell, and finished when you exit that shell. Allows multiple commands, etc. Plus it keeps more "formatting" infos, allowing replaying of some more things (like : clear screen, etc) (but that also can mess up the output... ymmv)
Jun
20
comment How to both display a command line's output on console and save the output into a text file?
I'd add "2>&1" before the "|"
Jun
14
answered What is the cause of root's being 100%?
May
23
comment Shortcut to clear command line terminal
and Ctrl+l for clearing the screen (a bit like a stty -sane, but maybe a bit less potent and far reaching). Ctrl+l works in many apps, as well (it forces a redraw in vi, for example. Usefull when someone "write" or "wall" on it)
Apr
25
comment How do you cd into the first available folder without typing out the name?
many ways: cd */ or cd rea*/ if unsure there is only 1 subdir at all times (if using bash, you can also cd rea[TAB] .. in other shells too but the way to expand name may vary). If "/reallylongnamefolder" is an absolute path, same thing, but with '/' in front, for ex: cd /rea*/
Mar
31
comment Why does the terminal respond with “2” when I use who | wc -l
who displays each "terminal" (in a loose sense) loggued in (and what user was used to log in on each). You have 2 terminals
Mar
19
comment I can read from /dev/null; how to fix it?
that 666 mode is also a good reminder of the care you need to take with /dev/null ^^
Jan
17
comment How can I flip a single bit in a file?
hmm; on second read : the article claims it works all over, so even in file data, not just filesystem structure... (The wikipedia en.wikipedia.org/wiki/Btrfs page, section "Checksum tree and scrubbing", talks about checksums for both filesystem AND data, and that apparently is verified at each read? Nice! But with the limitations checksums have, of course. Betterh than nothing, in many cases, but not foolproof)
Jan
17
comment How can I flip a single bit in a file?
@Oli : you can simply have a loop, dd outpouting block by block (ie, like the above, but "skip=N", N being in 1..max) until you can grep a line from the file you wish to edit [try to generate a line that won't happen anywhere else... for example take it from a password generator, and long enough?]. Then you edit that particular block. remount, test if the change was reverted (which I doubt, see my comment in the top answer... there seems to be a confusion between file data (=content) and the filesystem structure itself (= how files and their content are organized) ?)
Jan
17
comment How can I flip a single bit in a file?
I wonder if the OP ( @Oli ) want's to corrupt a block (ie, the filesystem structure) or a file (ie, the content of a file??)... And I believe the btrfs claim of self-healing is about the former, not the latter? [how would a filesystem know which bit was flipped in a file? some kind of CRC?]. This answer is probably in the right, though, so +1. [but it may change more than a "single bit" ? or change something that can be healed more easily than a random bit happening "anywhere" ?]