Short Tips

# 2. Short Tips

Contents of this section

## 2.1 Moving directories between filesystems. Alan Cox, `A.Cox@swansea.ac.uk`

Quick way to move an entire tree of files from one disk to another

> `

>     (cd /source/directory; tar cf - . ) | (cd /dest/directory; tar xvfp -)

> `

## 2.2 Pointer to patch for GNU Make 3.70 to change VPATH behavior.Ted Stern, `stern@amath.washington.edu`

I don't know if many people have this problem, but there is a "feature" of GNU make version 3.70 that I don't like. It is that VPATH acts funny if you give it an absolute pathname. There is an extremely solid patch that fixes this, which you can get from Paul D. Smith `<psmith@wellfleet.com>`. He also posts the documentation and patch after every revision of GNU make on the newsgroup 'gnu.utils.bug'. Generally, I apply this patch and recompile gmake on every system I have access to.

## 2.3 How do I stop my system from fscking on each reboot? Dale Lutz, `dal@wimsey.com`

Q: How do I stop e2fsck from checking my disk every time I boot up.

A: When you rebuild the kernel, the filesystem is marked as 'dirty' and so your disk will be checked with each boot. The fix is to run:

rdev -R /zImage 1

This fixes the kernel so that it is no longer convinced that the filesystem is dirty.

Note: If using lilo, then add `read-only` to your linux setup in your lilo config file (Usually /etc/lilo.conf)

## 2.4 How to avoid fscks caused by "device busy" at reboot time. Jon Tombs, `jon@gtex02.us.es`

If you often get device busy errors on shutdown that leave the filesystem in need of an fsck upon reboot, here is a simple fix:

To `/etc/brc` or `/sbin/brc`, add the line

> `

>     mount -o remount,ro /mount.dir

> `

for all your mounted filesystems except /, before the call to umount -a. This means if, for some reason, shutdown fails to kill all processes and umount the disks they will still be clean on reboot. Saves a lot of time at reboot for me

## 2.5 How to print pages with a margin for hole punching. Mike Dickey, `mdickey@thorplus.lib.purdue.edu`

> `

>             #!/bin/sh
>             # /usr/local/bin/print
>             # a simple formatted printout, to enable someone to
>             # 3-hole punch the output and put it in a binder

>             cat $1 | pr -t -o 5 -w 85 | lpr

> `

## 2.6 A way to search through trees of files for a particular regular expression.Raul Deluth Miller, `rockwell@nova.umd.edu`

I call this script 'forall'. Use it like this:

> `

>     forall /usr/include grep -i ioctl
>     forall /usr/man grep ioctl

> `

Here's forall:

> `

>     #!/bin/sh
>     if [ 1 = `expr 2 \> $#` ]
>     then
>             echo Usage: $0 dir cmd [optargs]
>             exit 1
>     fi
>     dir=$1
>     shift
>     find $dir -type f -print | xargs "$@"

> `

## 2.7 A script for cleaning up after programs that creat autosave and backup files.Barry Tolnas, `tolnas@nestor.engr.utk.edu`

Here is a simple two-liner which recursively descends a directory hierarchy removing emacs auto-save (~) and backup (#) files, .o files, and TeX .log files. It also compresses .tex files and README files. I call it 'squeeze' on my system.

> `

>     #!/bin/sh
>     #SQUEEZE removes unnecessary files and compresses .tex and README files
>     #By Barry tolnas, tolnas@sun1.engr.utk.edu
>     #
>     echo squeezing $PWD
>     find  $PWD \( -name \*~ -or -name \*.o -or -name \*.log -or -name \*\#\) -exec
>     rm -f {} \;
>     find $PWD \( -name \*.tex -or -name \*README\* -or -name \*readme\* \) -exec gzip -9 {} \;

> `

Next Chapter, Previous Chapter

Table of contents of this chapter, General table of contents

Top of the document, Beginning of this Chapter