6 ms·
ask hacker news: what other utilities do you know that others don't? :)
by pkrumins 18y ago
ask hacker news: what other utilities do you know that others don't? :)
- gcv 18y agoI was happy to discover rlwrap. Not every REPL or utility-with-its-own-prompt out there supports readline by default.
- jsrn 18y agommv (moves multiple files based on a simple pattern replacement language). Example: mmv "*.mp3" "old_#1.mp3" prefixes all files in the current directory ending with .mp3 with 'old_'. Btw., the quotes around the arguments are necesssary because mmv uses some of the same metacharacters as the shell does. Multiple substitutions are allowed, e.g.: $ mmv "*.*" "#1___#2" renames blub.xyz to blub___xyz.
- nuclear_eclipse 18y agoI've been looking for something like that for years!
- moe 18y agoI commonly use qmv (from renameutils): qmv, qcp - Rename or copy files quickly, editing the file names in a text editor Found nothing better for bulk renames because you get to use all the pattern/replace power of your favorite editor instead of learning some wierd specialized grammar through trial & error. This is how to remove all spaces from mp3 filenames using vim: qmv -f do *.mp3 :%s/ /_/g :wq
- jsrn 18y agofor Emacs users, there is wdired mode, which makes a directory listing editable just like a normal Emacs buffer.
- yters 18y agoA lot of what I find lacking in a standard terminal, Emacs makes up for with its shell and terminal emulators. I find that an editable buffer with the contents of my entire session to be eminently powerful when combined with keyboard macros and the search/replace commands.
- puffythefish 18y agoHas anyone had any luck getting this to compile for OS X (Leopard)? make seems to fail on an error for me.
- mark_h 18y agoAndrew Myers has a shell script called mvsed that does something similar, using sed to specify the patterns. Found it: http://www.cs.cornell.edu/andru/useful.html http://www.cs.cornell.edu/andru/useful.html
- nickb 18y agoAnyone know where to find a source tarball that compiles under Leopard? All I've found is a bunch of precompiled Linux RPMs...
- deleted 18y ago[deleted]
- jsrn 18y agohm - no source tarball, but perhaps others find this Leopard binary useful: http://www.joel.lopes-da-silva.com/articles/computer-science-technology/tips-tricks/79-mmv-under-mac-os-x-leopard-for-mac-intel.html http://www.joel.lopes-da-silva.com/articles/computer-science... (including man pages etc.) Caveat: I didn't try it myself (I don't have Leopard).
- ruby_roo 18y agoUpdate your MacPorts. It was just added: http://trac.macports.org/changeset/46335 http://trac.macports.org/changeset/46335
- Erwin 18y agoThere's a 'rename' script that comes with Perl that also does this, which may be useful if you want some really fancy renames. E.g. rename '$_=lc' *.MP3 to change case to lowercase.
- jarekr 18y agoZsh has a module called zmv which lets you do things like: zmv '(??)-(*).mp3' '$1 - ${(C)2:gs/_/ }.mp3' Which would change "01-foo_bar_baz.mp3" into "01 - Foo Bar Baz.mp3"
- yan 18y agoA short list of what I like and use: the command 'tee': let's you see what is happening at an intermediate stage of a pipeline (I originally thought your blog post would be about tee) the -S flag to objdump: If you're trying to learn how compilers work or assembly, the '-S' flag to objdumb is absolutely beautiful. If you compile a binary with debugging symbols (-g in gcc), 'objdump -S binary' will intersperse the assembly with the original code, letting you see what each line compiled into. I use 'pushd' and 'popd' bash builtins. It lets you remember current directories and have a stack of locations that you've been. Very valuable when you're jumping around a large source tree. Even though not a command, I usually follow ls by "-ltr". That arranges it such that the most recently modified file is on the bottom. Very easy to see what files were modified. "du -sk * | sort -rn" for a nice listing of directory sizes. Pressing "esc, ." (That's the Esc key, followed by a period. Not together) in bash would insert the previous command's argument. i.e.: bash# ls /some/really/long/path/to/a/huge/file.c bash# vi [esc, .] # <-- that would insert the path bash# vi $_ # <-- same effect 'tree' is nice to picture a directory hierarchy.
- gcv 18y agoLooks like the Esc-. trick works in zsh as well. I didn't know about it. Cool. Thank you. With regard to pushd and popd: these tricks work in zsh also. In addition, (again, zsh-specific) you can set these options: setopt auto_pushd # automatic directory stack setopt pushd_minus # swap +/- for pushd and popd setopt pushd_silent # no output after pushd and popd setopt pushd_to_home # pushd with no arguments goes to ~ setopt pushd_ignore_dups # no duplicates in directory stack With these options set, every time you change directories using cd, the directory goes into your directory stack, basically executing an implicit pushd. Then, move around the directory structure a little, and try typing 'cd -<Tab>' (meaning type 'cd -' and press Tab for autocompletion). It'll list entries in your directory stack by number (so -1 is your previous directory, -2 is the one before, and so on). It's a handy wrapper for bare pushd/popd functionality. Bash might offer similar functionality, but I don't know much about bash.
- likpok 18y agoI doubt it. One of the big features of zsh over bash is the tab completion is fantastic (arguments, URLS, etc). With a good .zsh and .zshrc, it is an amazing experience.
- pwk 18y agoI find xargs handy, it lets you use the output of one command as arguments for another command. As an example, I have a little alias that I use to grep through my ruby/rails source trees: alias gr 'find . -name \*.rb -o -name \*.rhtml -o -name \*.erb -o -name \*.rjs | xargs egrep \!*' (backticks can be used similarly, but can run into command line length limits)
- pwk 18y agoOh, and of course netcat (nc). Indispensable for debugging anything TCP/IP based. echo -n 'GET / HTTP/1.0\r\n\r\n' | nc news.ycombinator.com 80 Of course there are more specific tools for specific protocols, like curl or wget for http, but nc is the swiss army knife.
- yan 18y agonc is also awesome for quick and dirty file/directory transfer over the wire: host1 (receiving): nc -l 6123 > tar xfz - host2 (sending ): tar cfz - directory/ | nc host2 6123
- alnayyir 18y agoyou know, it's cool that you do that (quite neat in fact), but why is this better than scp'ing something, pray tell?
- meredydd 18y agoMy favourite two reasons for using it: 1. I often tend to use it when I want to pipe the output into a command. If it's a big transfer, I don't really want to have to stream several gigabytes of data onto disk, then off it, then back on again. Restoring a database dump is one example: me@host1$ nc -l -p <port> < db_dump.sql postgres@host2$ nc <host> <port> | psql db-name 2. The other big advantage over scp is that sometimes, your target (deliberately) isn't accessible directly from an SSH login. In the example above, I want to process that data as the 'postgres' user, but there's no way I'm allowing direct logins as that user. 'root' is, of course, the other common example.
- yan 18y agoFirstly, if the two machines are on the same switch this method is noticeably faster than scp'ing something large. The actual main reason though, is that this isn't limited to tarring over a network. What it comes down to, is you can almost seamlessly have a shell pipeline and one of those stages jumps a machine boundary.
- jacquesm 18y agonot really a utility but a very handy one liner to check if someone is being annoying on a http server: tail -1000 logfile | cut -d ' ' -f 1 | sort | uniq -c | sort -n Bots should stand out in the last couple of lines and have a linecount that is substantially higher than a normal user.