Make Unix Command Paths
mkunixcmds is a simple Bash script to generate a Unix command paths macro specification file (for example, unixcmds_redhat_linux_macros.cfg).
As with other scripts, we source this script from a mkunixcmds_programs.cfg PIKT configuration file (not shown). The end-use, target script follows.
#!/bin/bash # mkunixcmds -- make a unix command paths macro specification file for c in `find /bin /usr/bin /sbin /usr/sbin -print | awk -F/ '{print $NF}' | sort | uniq` do p=`which $c 2>/dev/null | tail -1` if [ X$p != X ] then echo "$c $p" fi done
We take the 'tail -1' of 'which' in the line
p=`which $c 2>/dev/null | tail -1`
to handle the special situations where a command might resolve to an alias.
Before using this script, make sure that /bin, /usr/bin, /sbin & /usr/sbin are all in your environment path. Add additional bin directories as needed.
Note that some additional cleanup may be required.
For more examples, see Samples.