All Tips


14

Tip #189   Remove every file but one

It's easy to remove (or copy, move etc.) all files that match a given criteria, but harder to move all but ones excluded by a criteria.

To do this we can combine grep's -v option with Unix command substitution:

Read more »

14

Tip #147   Find and Grep

Find all files with given name (you can use Bash expansion if you'd like), and Grep for a phrase:
Read more »

14

Tip #154   Port forwarding that automatically disconnects

If you want to tunnel a long-lived connection over SSH such that the tunnel goes away when the application disconnects, try something like the following example:

Read more »
  • TAGS:

14

Tip #224   Add header/footer to command output

If you want to surround the output of a command by a header or a footer try the following:

Read more »

14

Tip #141   Process files whose names may contain spaces

If the names of some of the files in a directory may contain spaces, combine find's "-print0" option with xargs' "-0" option:

# this will behave incorrectly if some files or directories have spaces:
find . -type f | xargs ls -l

# this will work correctly:
find . -type f -print0 | xargs -0 ls -l Read more »
  • TAGS:

13

Tip #172   Create daily backups

To create a set of backed up files with the current date added at the end of the file name try the following:

Read more »

13

Tip #209   Directory Tree

The following alias will print the directory structure from the current directory in tree format.

Read more »

13

Tip #200   Pushd and Popd

Use pushd and popd to store directories to go back to later:

Read more »

13

Tip #95   Bash terminal size

Q: If I resize my xterm while another program is running, why doesn't bash notice the change?
http://cnswww.cns.cwru.edu/~chet/bash/FAQ (E11)

Bash won't get SIGWINCH if another process is in the foreground.
Enable checkwinsize so that bash will check the terminal size when
it regains control.

Put this in your bash config somewhere (e.g. Gentoo has it in /etc/bash/bashrc):

Read more »