commandlinefu.com is the place to record those command-line gems that you return to again and again.
Delete that bloated snippets file you've been using and share your personal repository with the world. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
You can sign-in using OpenID credentials, or register a traditional username and password.
First-time OpenID users will be automatically assigned a username which can be changed after signing in.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for:
N: On the current line, sed will display it on pattern space, plus a \n (new line); but
s/\n//: Will get rid of new line displayed on pattern space, joining the current line's end with the start of the next line
Useful in scripts.
Access a random news web page on the internet.
The Links browser can of course be replaced by Firefox or any modern graphical web browser.
Replaces the first instance of 'foo' with 'bar'. To replace all instances of 'foo' with 'bar': !!:gs/foo/bar/
Uses ImageMagick and potrace to vectorize the input image, with parameters optimized for xkcd-like pictures.
(In French) Connection aux hotspots FreeWifi, et maintien de la connection active
This dumps serial numbers of all the drives but HP warranty check does not say they are valid ...
Display recursive file list (newest file displayed at the end) and be free to access last file in the list simply by pressing arrow_up_key i.e. open it with joe editor.
BTW IMHO the list of files with newest files at the end is often more informative.
Put this 'lsa' function somewhere in your .bashrc and issue
. ~/.bashrc
or
source ~/.bashrc
to have access to the 'lsa' command immediately.
.
(the function appends command "joe last_file_in_the_list" at the end of command history)
Muestra el crecimiento de un archivo por segundo.
Cambia el texto "FILE" por el nombre del archivo a monitorear.
Comando STAT
Muestra el crecimiento de un archivo por segundo.
Cambia el texto "FILE" por el nombre del archivo a monitorear.
Comando LS + AWK
Summarize established connections after netstat output.
Using tee and /dev/stderr you can send one command output to terminal before executing wc so you can summarize at the bottom of the output.
Starting with a large MySQL dump file (*.sql) remove any lines that have inserts for the specified table. Sometimes one or two tables are very large and uneeded, eg. log tables. To exclude multiple tables you can get fancy with sed, or just run the command again on subsequently generated files.
From the manpage:
man less
-X or --no-init
Disables sending the termcap initialization and deinitialization strings to the terminal. This is sometimes desirable if the deinitialization string does something unnecessary, like clearing the screen.
Bonus:
If you want to clear the screen after viewing a file this way that had sensitive information, hit or just type clear. Since is readily available, I don't know why less bothers to automatically clear. If you're viewing the file at all, chances are you want to see the output from it after you quit.
Assuming you've written all of
make -j hfst-tokenize && echo doavtter gr?dakursa|./hfst-tokenize --gtd tokeniser-gramcheck-gt-desc.pmhfst
and want that to execute every time you :w in vim (or C-xC-s in Emacs), just hit and it'll turn into
while true; do ( make -j hfst-tokenize && e doavtter gr?dakursa|./hfst-tokenize --gtd tokeniser-gramcheck-gt-desc.pmhfst ); inotifywait -q -e modify -e close_write *; done
with the cursor right before the ')'. Hit enter, and it'll run on each save.
Requires the package inotify-tools installed.
This command uses the "exiftool" command which is available here: http://www.sno.phy.queensu.ca/~phil/exiftool/
NB, there should be a degree symbol right after the first "%d" NOT a question mark.
For some unknown reason, commandlinefu is not able to handle degree symbol correctly ("?")?
This command works by rsyncing the target directory (containing the files you want to delete) with an empty directory. The '--delete' switch instructs rsync to remove files that are not present in the source directory. Since there are no files there, all the files will be deleted.
I'm not clear on why it's faster than 'find -delete', but it is.
Benchmarks here: https://web.archive.org/web/20130929001850/http://linuxnote.net/jianingy/en/linux/a-fast-way-to-remove-huge-number-of-files.html
Will append lines to the hosts file to do some basic ad blocking.
This command line assumes that "${url}" is the URL of the web resource.
It can be useful to check the "freshness" of a download URL before a GET request.
Should work even when very large files exist.