Live data from Hacker News

New(ish) command line tools

jvns.ca

91–100 of 252 posts

Re: New(ish) command line tools

#92

A simple trick I only figured recently is following logs with fuzzy search: tail -f /var/log/foo.log | fzf +s Or something similar for output from a dev server: make serve | fzf --ansi +s

Could you (or anyone who understands) explain what these do?

It just takes the last ten lines of a log file, then passes that input to a program that basically lets you search each line. I don't really see the usefulness.

Edit: Ah, I see. According to another comment you see the output of the file as it changes.

Re: New(ish) command line tools

#93
post #54

Earlier quoted context omitted.

Just posting this without trying it out...grep -nH gives you line numbers and full filepath context, and as another commenter said, -ve allows you to string multiple excludes, so grep -inH -ve not_this -ve nor_this -ve nor_that.

You don’t have to stack -v like that: -v inverts all the -e expressions, so this should be equivalent: grep -inHv -e foo -e bar -e baz

So, awk sort of works as a fancy grep:

    ps axjw | awk '(/zsh/ || /login/) && !(/awk/ || /direnv/)'
And you can easily add features like "print the first line unconditionally:

    ps axjw | awk 'NR == 1 {print} (/zsh/ || /login/) && !(/awk/ || /direnv/)'
IMO, awk is in a pretty uniquely sweet spot between grep and perl/ruby/python.

Re: New(ish) command line tools

#94

Earlier quoted context omitted.

Could you (or anyone who understands) explain what these do?

It just takes the last ten lines of a log file, then passes that input to a program that basically lets you search each line. I don't really see the usefulness. Edit: Ah, I see. According to another comment you see the output of the file as it changes.

`tail -f` follows the logfile, so the command allows you to search over the logfile as logs are being added to it

Re: New(ish) command line tools

#96
post #7

Couple ones there that I’m keen to try out. bat in particular seems like such an easy win

Every time I see these lists, I tell myself i'll start using these, but always forget.

I would love a meta tool that, every time I use one of the old tools, it automatically gives me a notice to use the new one instead, so I can learn. Then again I guess I could alias the old ones to point to the one one.

Re: New(ish) command line tools

#97

A simple trick I only figured recently is following logs with fuzzy search: tail -f /var/log/foo.log | fzf +s Or something similar for output from a dev server: make serve | fzf --ansi +s

Alternatively, you can use less(1) in tail mode to search growing logs.

  less +F -p pattern /path/to/log
(Ctrl-C to break out of tail mode. /pattern to interactively set search pattern.)

Re: New(ish) command line tools

#99
macOS equivalent of locate: mdfind. This actually uses Spotlight, so it can search for files by content as well as by name.

    # search by content:
    $ mdfind some_string
     
    # search by name:
    $ mdfind -name my_file.txt
Both commands return a list of files matching the query.

Re: New(ish) command line tools

#100
post #3

direnv is such a godsend that I shill for it on every team and in every company now, it's such a great tool.

I read through the direnv docs, but I'm trying to think of how I'd use it. Can you or anyone else give me some examples? Even just listing which directories you have .env or .envrc files in, and what environment variables you use in them.
Post reply on HN