All Tips


14

Tip #193   Make multiple files or directories

Save time when making multiple files or directories (or performing any command requiring a list) where the file names only slightly differ.

Read more »

29

Tip #192   Print a random shell-fu tip

Print a random shell-fu tip:
Read more »

10

Tip #190   dos2unix all files in a directory

dos2unix requires the name of an input and output file so it can be hard to run on a list of files. The following gets around this and will run dos2unix on all files in a directory:

Read more »

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 »

11

Tip #187   View non-printing characters with cat

You can view unprintable and non ASCII characters in a file with 'cat -v -t -e'

Example:

Read more »

8

Tip #186   Using comm

You can use diff to see the differences between two files, but it can be useful to see what is the same and more clearly how they differ. This is where comm comes in useful.

comm tells you what information is common to two lists and what information appears uniquely in one or the other.

Read more »

165

Tip #185   CDPATH

This is a little known and very underrated shell variable. CDPATH does for the cd built-in what PATH does for executables. By setting this wisely, you can cut down on the number of key-strokes you enter per day.

For example:
Read more »

29

Tip #183   Always running

This checks if a daemon is running, if not it starts the daemon. Great for daemons that need to always be running. Can be used with cron

ps -C someprogram || { someprogram & }

// sil at infiltrated dot net Read more »
  • TAGS:
  • ps

5

Tip #182   MAC address conversion

Convert mac addresses such as 000000abde00 into 00:00:00:ab:de:00

awk '{for(i=10;i>=2;i-=2)$0=substr($0,1,i)":"substr($0,i+1);print}' macaddress_list
sed 's/\(..\)/\1:/g;s/:$//' macaddress_list

// sil at infiltrated.net
Read more »