Live data from Hacker News

Favorite Unix Commands

clippy.in

71–80 of 135 posts

Re: Favorite Unix Commands

#71
post #28

Please comment if you have a favorite not on this list.

When rewriting large amounts of ASCII text (or comments in Code), I really find "par" helpful. : Just use it in : : vi with your cursor in front of a badly wrapped block of text. : : Press !}par and the text will be : : piped to par : : which fixes up : : the : : formatting and keeps aligned frame markers : : intact magically. : : Just use it in vi with your cursor in front of a badly wrapped : : block of text. Press…

Or you can just select the block of text and type gq. This will do what par does, and can be adjusted with vim's 'textwidth' and 'formatoptions' settings.

Re: Favorite Unix Commands

#72
post #51

sudo !! Instant favorite

Along the lines of magic shell variables, there's also '!$', which selects the last argument of the previous command. Often I'm looking at different aspects of the same file:

    $ file foo
    $ ls -lh !$
    $ vim !$

Re: Favorite Unix Commands

#73
post #7

I forgot about the DNS querying of wikipedia. Probably could've used that to entertain myself on my flights over the holidays since I'm pretty sure gogo inflight passes DNS through. Anyway, I'm a big fan of piping things into xargs. xxd is a terminal-based hex editor. It can convert both to and from hex to binary. I also use 'pgrep -lf 'partial_program_name' a lot in place of 'ps aux | grep partial_program_name'. 'pk…

+1 for xxd, great for debugging purposes e.g. analysing serial output from socat (also mentioned by another commentor below).

Re: Favorite Unix Commands

#75
post #58
post #53

Earlier quoted context omitted.

Normal mode (:help :! for more information on this command).

What benefit does :!sudo tee % have over doing it at the command line other than filling in the current filename for you? I suspect the original poster meant something like "gg!Gsudo tee %".

:w !sudo tee %

Re: Favorite Unix Commands

#76
post #51

sudo !! Instant favorite

I don't find this one useful. [up-arrow] automatically inserts the last command, which gives a generic mechanism to correct the command and it requires no more typing than !!: [up-arrow][control-a]sudo [enter]

Re: Favorite Unix Commands

#77
post #51

sudo !! Instant favorite

I don't find this one useful. [up-arrow] automatically inserts the last command, which gives a generic mechanism to correct the command and it requires no more typing than !!: [up-arrow][control-a]sudo [enter]

moving your hand over to arrow keys is why I would use the sudo !! version.

Re: Favorite Unix Commands

#78
post #20

I have this in my .bashrc: function lc() { if [[ "$#" -gt 1 ]]; then for DIR in "$@"; do echo -n "$DIR - " ; ls -AU1 $DIR | wc -l ; done ; else ls -AU1 "$@" | wc -l ; fi; } So, "lc /dir" will count the number of files in /dir and "lc /dir/*" will count the files in subdirectories of /dir. This is useful if you're working in an environment where you may have thousands of files in a directory, and a regular "ls -l" wil…

Here's an idea: always pipe ls throug a pager! If it's less than a page, it would just print the results (you have to set some flags on less that I don't remember). If it's more, then press d or /term-to-search :)
Post reply on HN