Tips tagged bash


3

Tip #562   Version all unversioned files in an SVN checkout

Sometimes, you want to add a lot of files to SVN from the command line. This simple command will find all unversioned files in an SVN checkout and adds them to SVN versioning.

Read more »

2

Tip #557   Randomize lines in a file

The bash shell has a variable called $RANDOM, which outputs a pseudo-random number every time you call it. This allows you to randomize the lines in a file for example:

Read more »

20

Tip #551   My code is compiling

Simulate a never-ending compilation so you have an excuse for why you're browsing the net (see http://xkcd.com/303/):

Read more »

4

Tip #549   Splitting arguments with read

The 'read' command can be used to split arguments based on any arbitrary character using IFS:

Read more »

4

Tip #544   Change extension of files in the current directory

This tip is inspired by #27 ( http://www.shell-fu.org/lister.php?id=27 ) which I think is misleading, here's a much more reliable and efficient version:

Read more »

5

Tip #533   User input timeout

In bash scripting if you have a situation where you don't want to wait forever for a user to respond, you can use the read command with the -t option which causes read to time out in "number of seconds" specified.

From read command man page:

-t timeout : Cause read to time out and return failure if a complete line of input is not read within timeout seconds. This option has no effect if read is not reading input from the terminal or a pipe.

-p prompt : Display prompt, without a trailing newline, before attempting to read any input. The prompt is displayed only if input is coming from a terminal.

Example:
Read more »

4

Tip #502   Counts files in the current directory and subdirectory

Counts files in the current directory and subdirectory
Read more »

6

Tip #497   Insert last argument

<esc>-. (that's 'escape' followed by '.') inserts the last arguments from your last command. It comes in handy more than you think.

Read more »

6

Tip #481   ESC-g for glob expansion in bash

Like <TAB> expands a filename given a prefix you can also expand a file name given the middle part of a file name using escape and then 'g'.

Read more »