Commands by xiyah23 (0)

  • bash: commands not found

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

Stat each file in a directory
Possible simplification of egrep-awk-sort with find and -exec with xargs.

Create a backdoor on a machine to allow remote connection to bash
This will launch a listener on the machine that will wait for a connection on port 1234. When you connect from a remote machine with something like : nc 1234 You will have console access to the machine through bash.

Create Solid Archive (best compression) with 7z
Creates a solid archive with the highest possible compression (Ultra). Advantage of 7z is that it will use all the processor cores to create the archive. (Ok. at least version 9.04 does)

Copy the sound content of a video to an mp3 file
-vn removes tha video content, the copy option tells ffmpeg to use the same codec for generating the output

Create subversion undo point
Allows you to save progress without committing. To revert to an undo point, svn revert then apply the undo point with patch. $ svn revert -R . && patch -p0 < .undo/2009-03-27_08:08:11rev57 Similar:

count how many times a string appears in a (source code) tree
grep -o puts each occurrence in a separate line

Adequately order the page numbers to print a booklet
Useful if you don't have at hand the ability to automatically create a booklet, but still want to. F is the number of pages to print. It *must* be a multiple of 4; append extra blank pages if needed. In evince, these are the steps to print it, adapted from : 1) Click File ▸ Print. 2) Choose the General tab. Under Range, choose Pages. Type the numbers of the pages in this order (this is what this one-liner does for you): n, 1, 2, n-1, n-2, 3, 4, n-3, n-4, 5, 6, n-5, n-6, 7, 8, n-7, n-8, 9, 10, n-9, n-10, 11, 12, n-11... ...until you have typed n-number of pages. 3) Choose the Page Setup tab. - Assuming a duplex printer: Under Layout, in the Two-side menu, select Short Edge (Flip). - If you can only print on one side, you have to print twice, one for the odd pages and one for the even pages. In the Pages per side option, select 2. In the Page ordering menu, select Left to right. 4) Click Print.

Put uppercase letters in curly brackets in a BibTeX database
It is often recommended to enclose capital letters in a BibTeX file in braces, so the letters will not be transformed to lower case, when imported from LaTeX. This is an attempt to apply this rule to a BibTeX database file. DO NOT USE sed '...' input.bib > input.bib as it will empty the file! How it works: $ /^\s*[^@%]/ Apply the search-and-replace rule to lines that start (^) with zero or more white spaces (\s*), followed by any character ([...]) that is *NOT* a "@" or a "%" (^@%). $ s===g Search (s) for some stuff and replace by other stuff. Do that globally (g) for all matches in each processed line. $ \([A-Z][A-Z]*\)\([^}A-Z]\|},$\) Matches at least one uppercase letter ([A-Z][A-Z]*) followed by a character that is EITHER not "}" and not a capital letter ([^}A-Z]) OR (|) it actually IS a "}", which is followed by "," at the end of the line ($). Putting regular expressions in escaped parentheses (\( and \), respectively) allows to dereference the matched string later. $ {\1}\2 Replace the matched string by "{", followed by part 1 of the matched string (\1), followed by "}", followed by the second part of the matched string (\2). I tried this with GNU sed, only, version 4.2.1.

Watch and cat the last file to enter a directory
Great for watching things like Maildir's or any other queue directory.

Show which process is blocking umount (Device or resource is busy)
Instead of using force un-mounting, it's better to find the processes that currently use the relevant folder. Taken from:

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: