commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
The '1' in '%01d' changes the amounts of digits in the integer, eg. 1 vs 0001.
It'll print the file names preserving the spaces in their names and adding new line after every new filename.
I wrote this to quickly find out how many files in any directory is owned by a particular user. This can be extended using pipe and grep to do much more.
This command will take the files in a directory, rename them, and then number them from 1...N.
Black belt stuff.
Hell of a time saver.
I did not like two things in the submitted commands and fixed it here:
1) If I do cd - afterwards, I want to go back to the directory I've been before
2) If I call up without argument, I expect to go up one level
It is sad, that I need eval (at least in bash), but I think it's safe here.
eval is required, because in bash brace expansion happens before variable substitution, see http://rosettacode.org/wiki/Repeat_a_string#Using_printf
http://www.joachim-breitner.de/projects#screen-message now also supports reading stdin continuously to update what it shows, different ?slides? separated by a form feed character. Here, we feed the current time into it each second to create a large clock.
Shows the ?rendering? for each of the 256 colours in both the bold and normal variant. Using seq is helpful to get even lines, passing $((COLUMNS*2)) to column sort-of-handles the nonprintable characters.
if you have a capture file *.eth, and ajp protocol is in use on port 9009, you can paste the above command. You can change the fiile and port name
Lists the size in human readable form and lists the top 25 biggest directories/files
Unlike other alternatives, this command only relies on bash builtins and should also work on windows platforms with the bash executable.
Sparseness corresponds to the number 128 and can be adjusted. To print all possible digits instead of only 0 and 1 replace RANDOM%2 by RANDOM%10 or RANDOM%16 to add letters [A-F].
Can't see it here, but the non-breaking space is highlighted :)
cat -t -e
achieves something similar, but less colourful.
Could add more code points from https://en.wikipedia.org/wiki/Space_%28punctuation%29#Spaces_in_Unicode
I don't think it's possible to give a (background) colour to the tab itself, since a tab is, IIUC, simply a command to the terminal to move to the right. Nevertheless, this "highlighting" can be helpful when working with tab-separated files.
Counts the files present in the different directories recursively. One only has to change maxdepth to have further insight in the directory hierarchy.
Found at unix.stackexchange.com:
Prints 0's and 1's in The Matrix style. You can easily modify to print 0-9 digits using $RANDOM %10 insted of %2.
This command will find the highest context switches on a server and give you the process listing.
Could easily be used for lowercase --> ((i=97;i
usage: alarmclock TIME
TIME is a sleep(1) parameter which tells function how long to wait until raise the alarm.
printf reapeats the format as longer as it has arguments. Then the idea is to make cut retain as much fields as we have elements in the array.
As usual with such join/split string manipulation, you have to make sure you don't have conflicts between your separator and your array content.
Sometimes you want to see all of the systcls for a given $thing. I happened to need to easily look at all of the vm sysctls between two boxes and compare them. This is what I came up with.
Group membership in OS X is a mish-mash of standards that end up meaning there's almost a half-dozen of ways to belong to a group, what with group inheritance and automatic assignment. This means there's no easy command to find out all groups a user belongs to. The only sensible way then is to list all users and then query each user for membership.
NOTE: This is a function. Once input you can execute it by calling with a groupname.
Use tput cols to find the width of the terminal and set it as the minimum field width.