All Tips


-11

Tip #42   Count total number of occurances of a string in all files in the

#!/bin/ksh

#KSH only.
# Author: simonvc
# Purpose: Count the total number of occurances of a pattern in all files in the cwd.
# Alt: you could also do "$(grep $pattern * | wc -l) but where's the fun in that ;-)


pattern="WHATEVER"

$ echo $(($(grep -hc $pattern *| tr "\n" "+")"0"))
Read more »

11

Tip #43   Using Perl instead of Sed

Prefer Perl over Sed? No problem! To use Perl as a Sed-like program:
Read more »

3

Tip #44   Using tar with other compression formats

GNU tar comes with native support for gzip, bzip2, and compress (adaptive LZ, LZW). However, many other useful compression algorithms exist, but most implementations of them don't support all the file system metadata that tar does. There are two general methods to using tar with arbitrary compression programs: via an option in tar itself and via piping. The first:
Read more »

108

Tip #45  

multiple command output into a single program:

diff -u <(ls -c1 dir_1) <(ls -c1 dir_2)

Will show you a diff of files in the root of dir_1 and dir_2 Read more »

418

Tip #46  

Using expansion to move a file aside without having to type the file name twice

Read more »

45

Tip #47   Changing file extensions

Rename replaces string X in a set of file names with string Y.

Read more »

4

Tip #48   Check low space

Mail somebody about space running low in some path (ksh, bash):

Read more »