Commands using cut (573)

What's this? 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.

Share Your Commands

Check These Out

find which of the zip files contains the file you're searching for
This command find which of your zip (or jar) files (when you have lots of them) contains a file you're searching for. It's useful when you have a lot of zip (or jar) files and need to know in which of them the file is archived. It's most common with .jar files when you have to know which of the .jar files contains the java class you need. To find in jar files, you must change "zip" to "jar" in the "find" command. The [internal file name] must be changed to the file name you're searching that is archived into one of the zip/jar files. Before run this command you must step into the directory that contains the zip or jar files.

make 100 directories with leading zero, 001...100, using bash3.X

Extract rpm package name, version and release using some fancy sed regex
This command could seem pretty pointless especially when you can get the same result more easily using the rpm builtin queryformat, like: $ rpm -qa --qf "%{NAME} %{VERSION} %{RELEASE}.%{ARCH}\n" | sort | column -t but nonetheless I've learned that sometimes it can be quite interesting trying to explore alternative ways to accomplish the same task (as Perl folks like to say: There's more than one way to do it!)

Most used command

Move all comments the top of the file in vim
Python comments begin with a #. Modify to suit other languages. Other uses: Instead of m0 use m$ for end of file or d for deleting all comments.

Check wireless link quality with dialog box
The variable WIRELESSINTERFACE indicates your wireless interface

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

Shuffle mp3 files in current folder and play them.
* grep -i leaves only mp3 files (case insentitive) * sort -R randomizes list (may use GNU 'shuf' instead). * the sed command will add double quotes around each filename (needed if odd characters are present)

write the output of a command to /var/log/user.log... each line will contain $USER, making this easy to grep for.
This command is useful if you want to copy the output of a series of commands to a file, for example if you want to pastebin the output from 'uname -a', 'lspci -vvv' and 'lsmod' for video driver trouble-shooting on your favorite Linux forum. 'log' takes all the following arguments as a command to execute, with STDOUT sent to /var/log/user.log. The command is echoed to the log before it is executed. The advantages of using logger (as opposed to appending output from commands to a file) are 1) commands are always appended to the logs... you don't have to worry about clobbering your log file accidentally by using '>' rather than '>>' 2) logs are automatically cleaned up by logrotate. The following functions allow you to mark the start and end of a section of /var/log/user.log. $ startlog() { export LOGMARK=$(date +%Y.%m.%d_%H:%M:%S); echo "$LOGMARK.START" | logger -t $USER; } then $ endlog() { echo "$LOGMARK.END" | logger -t $USER; } printlog will print all lines between $LOGMARK.START and $LOGMARK.END, removing everything that is prepended to each line by logger. $ printlog() { sudo sed -n -e "/$LOGMARK.START/,/$LOGMARK.END/p" /var/log/user.log| sed "s/.*$USER: //"; } The following command should dump just about all the information that you could possibly want about your linux configuration into the clipboard. $ startlog; for cmd in 'uname -a' 'cat /etc/issue' 'dmesg' 'lsusb' 'lspci' 'sudo lshw' 'lsmod'; do log $cmd; done; endlog; printlog | xsel --clipboard This is ready for a trip to, and you don't have to worry about leaving temporary files lying around cluttering up $HOME. Caveats: I'm sure that startlog, endlog, and printlog could use some cleanup and error checking... there are unchecked dependencies between printlog and endlog, as well as between endlog and startlog. It might be useful for 'log' to send stderr to logger as well.

Top 30 History
Top 30 History Command line with histogram display

Stay in the loop…

Follow the Tweets.

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.


Subscribe to the feeds.

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: