Reputation
386
Top tag
Next privilege 500 Rep.
Access review queues
Badges
1 6
Newest
 Yearling
Impact
~7k people reached

  • 0 posts edited
  • 0 helpful flags
  • 40 votes cast
Jun
24
comment How do I round numbers to the nearest integer from the command line?
The answers provided are good (and better than what I'm just about to mention), but just for the fun of mentionning it: a possibility is to add "0.5" to each number and keep just the integer part (for ex: drop the decimal part). There are many ways to do that one (and many caveats, especially when you reach the maximum value, which in turns depends on the program and its implementation)
Feb
20
comment How to find lines matching a pattern and delete them?
@terdon : it s all for the better good ^^ (and I did +1 already, though, as it's very informative for beginners)
Feb
20
comment How to find lines matching a pattern and delete them?
the bash one should use printf "%s\n" "$line" : quoting $line to preserve whitespaces, and avoiding some echo problems (interpreting special chars, etc). and avoids the need to add -- too.
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 ^^