376 reputation
16
bio website
location
age
visits member for 1 year, 7 months
seen Aug 15 at 23:35

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" ?]
Jan
9
awarded  Yearling
Nov
28
comment grep on --help doesn't work on some commands
@Loris1123: it's good to separate errors from normal output: that way you can inform about what happens, and that output (on stderr) is NOT taken as the output from the command (imagine a script that decide if grep something ce_fichier ; then do THIS ; else do THAT ; fi : if ce_fichier is not existant, grep can tell so on STDERR (if it did on STDOUT the "if" would see lines, and therefore believe that "something" was indeed in "ce_fichier" !). And adding '--help' to any command will output the help, so it better output this part on stderr...
Nov
21
comment How to clean /tmp?
@Rinzwind: please do :) I mentionned this on your answer to complete it (and to correct the statement about "harm").
Nov
21
comment How to clean /tmp?
... so using a who –b (date of last boot), and then creating a file /boottime dated at the time of booting ( touch ....... /boottime), will allow one to do a safe find /tmp -type f \( ! -newer /boottime \) -delete \;, deleting only files older than the last boot
Nov
21
comment How to clean /tmp?
the "without any harm" is true for files dating from before the last reboot. Otherwise it could be in use by a current program and (for that program) may cause issues... for example I have scripts that create files in /tmp, and then re-reads them to do the next step(s) of processing. deleting/truncating them in between will disrupt the program's actions (and could even lead to dangerous outcomes, depending what those files are used for)
Nov
13
comment What is the meaning of “ps -aef | grep $(pwd)” command?
it is probably used to find out processes whose binaries/scripts are located in (or underneath) the current directory. If you start a process with /path/to/the/file , and you go in /path/to, the ps -aef | grep $(pwd) will do a ps -aef | grep /path/to and should show that process as its full path is /path/to/the/file
Nov
12
comment How to get longest line from a file?
@don.joey: that's the power of unix. Simple commands, that can work together. here, he looks for "^.{n}$", ie any line that, between the beginning of line (^) and its end ($) has exactly n characters (.{n}). Then he just needs to find n: for this he uses a GNU-ism, "wc -L filename" (note that this is not posix) which returns the length of the longest line of filename. So he greps any line that has the longest length. $(cmd) is replaced by the output of cmd.