Continue a current job in the background and detach it from current terminal
zsh: list of files sorted by size, greater than 100mb, head the top 5. '**/*' is recursive, and the glob qualifiers provide '.' = regular file, 'L' size, which is followed by 'm' = 'megabyte', and finally '+100' = a value of 100
An example of zsh glob qualifiers.
Example of zsh globing, glob qualifier, and substitution: -Q state that the parameter will contain a glob qualifier. (**/)(*) is recursive (.) is our glob qualifier, with states the match is a file "." The first parameter $1, is then substituted with $2 but with lowercasing '(L)' ... a (U) would of course be from lower to upper.
Sony's Xperia camera app creates files without time-stamped names. Thus, after deleting files on the phone, the same names will be reused. When uploading the photos to a cloud storage, this means that files will be overwritten. Running this command after every sync of uploaded photos with the computer prevents this. Show Sample Output
ZSH ships a couple random number generators via the $RANDOM environment variable and rand48() via zsh/mathfunc, but neither are cryptographically secure. This code produces a 32-bit random number suitable for cryptography. It's only dependency is /dev/urandom and it does not rely on any shell commands or 3rd party utilities. It assumes ZSH was compiled with 64-bit integer support. Show Sample Output
Found another way, more compatible. Tested with xterm, aterm, gnome-terminal and rxvt (where it sets the window title) and guake (where it doesn't - after all, guake does not show the window title).
For all of the jpgs in a directory, determine their size and if below a threshold remove them forcefully.
On RHEL, Fedora and CentOS systems, and maybe others, the sbin directories aren't in the user's $PATH. For those systems that use 'sudo', this can be inconvenient typing the full path all the time. As a result, you can easily take advantage of adding the sbin directories to your PATH by adding this simple line to you .zshrc.
Col 1 is swapped sum in kb Col 2 is pid of process Col 3 is command that was issued Show Sample Output
Press > or < to go to the next or previous track. Space to toggle play/pause, etc. It creates a temp file descriptor. To see where the file descriptor gets created type: echo <(echo foo) This works better than running find first, then piping to mplayer with xargs or something, because that won't let you use keyboard shortcuts.
You can find a command's history event number via the `history` command.
You can also put the history event number in your prompt: \! for bash, or %h for zsh.
Finally, I would like to point out that by "number", I mean POSITIVE INTEGER. Not, say, a letter, such as 'm'. Examples:
!1
or
!975
Show Sample Output
Enhancement for the 'busy' command originally posted by busybee : less chars, no escape issue, and most important it exclude small files ( opening a 5 lines file isn't that persuasive I think ;) ) This makes an alias for a command named 'busy'. The 'busy' command opens a random file in /usr/include to a random line with vim.
You could avoid xargs and sed in this case (shorter command and less forking): At least bash and zsh have some mighty string modifiers. I would also suggest using find with exec option to get more flexibility. You may leave out or include "special" file for example.
this is the much easier zsh equivalent ...
whereis (1) - locate the binary, source, and manual page files for a command Not actually better, just expanded a bit. The "whereis" command has the following output: whereis gcc gcc: /usr/bin/gcc /usr/lib/gcc /usr/bin/X11/gcc /usr/share/man/man1/gcc.1.gz therefore the 'ls' error on first line, which could be eliminated with a little extra work. Show Sample Output
save as shell script and pipe your command output Show Sample Output
It gives a 'xcd' command for changing directory to one of CWDs of other ZSH processes (typically running in a terminal emulator). Useful for single-windowed terminal emulators like XTerm or Rxvt which don't have ability to pass CWD of one shell to another. Show Sample Output
Like the above, but runs a single rm command
end_w_nl filename
will check if the last byte of filename is a unix newline character. tail -c1 yields the file's last byte and xxd converts it to hex format.
recursively delete empty directories and directories which only contain empty directories using zsh globbing syntax. ** is for recursive globbing. *(/^F) matches all entries that are directories which are not full.
If you only want to delete empty directories and not those directories which contained only empty directories and will be empty afterwards, just leave out the options to rmdir:
rmdir **/*(/^F)
Uses zsh globbing syntax to safely remove all the files known to be generated by LaTeX, but only if there is actually a .tex source file with the same basename present. So we don't accidentally delete a .nav .log or .out file that has nothing to do with LaTeX, e/'[[ -f ${REPLY:r}.tex ]]'/ actually checks for the existance of a .tex file of the same name, beforehand.
A different way to do this, would be to glob all *.tex files and generate a globbing pattern from them:
TEXTEMPFILES=(*.tex(.N:s/%tex/'(log|toc|aux|nav|snm|out|tex.backup|bbl|blg|bib.backup|vrb|lof|lot|hd|idx)(.N)'/)) ;
rm -v ${~TEXTEMPFILES}
or, you could use purge() from grml-etc-core ( http://github.com/grml/grml-etc-core/blob/master/usr_share_grml/zsh/functions/purge )
This will check if a user is logged in using ssh and will log out the user automatically after the specified time in seconds without data retrieval on the server side. Will work with bash and zsh so put it into your sourced shell file on the server side. Be aware that users can change this themselves as it's just a envoronment variable. Show Sample Output
commandlinefu.com is the place to record those command-line gems that you return to again and again. 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.
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: