.TH "CLEANPATH" "1" "" "" "Utility" .hy .SH NAME .PP \f[B]cleanpath\f[R] \[em] Filters unwanted elements from an environment variable .SH SYNOPSIS .PP \f[B]cleanpath\f[R] [options] [pattern \&...] .SH DESCRIPTION .PP \f[B]cleanpath\f[R] filters unwanted elements from an environment variable. By default, this utility reads from the \f[I]PATH\f[R] envrionment variable. This behavior may be overridden using the \f[B]--env\f[R] option described below. .SS OPTIONS .TP \f[B]-h\f[R], \f[B]--help\f[R] Prints brief usage information. .TP \f[B]-V\f[R], \f[B]--version\f[R] Prints the current version number. .TP \f[B]-D\f[R], \f[B]--default\f[R] Prints the default operating system PATH .RS .PP No other arguments are honored and no filtering will occur. .RE .TP \f[B]--list\f[R] Format output as a list .TP \f[B]-e\f[R], \f[B]--exact\f[R] Filter when pattern is an exact match (default) .TP \f[B]-l\f[R], \f[B]--loose\f[R] Filter when any part of the pattern matches .TP \f[B]-r\f[R], \f[B]--regex\f[R] Filter matches with (Extended) Regular Expressions .TP \f[B]-s\f[R], \f[B]--sep\f[R] \f[I][str]\f[R] Use custom path separator (default: \f[I]`:'\f[R]) .RS .PP The separator may be a string longer than one byte. .RE .TP \f[B]-E\f[R], \f[B]--env\f[R] \f[I][str]\f[R] Use custom environment variable (default: \f[I]PATH\f[R]) .RS .PP The environment variable passed to \f[B]-E\f[R] must exist. .RE .SH EXAMPLES .SS A typical user PATH .PP /opt/special/bin:/usr/local/programX/bin:/usr/local/bin:/usr/bin:/bin .IP "1." 3 Filter only \f[I]/usr/local/bin\f[R] .RS 4 .PP cleanpath -e /usr/local/bin .PP /opt/special/bin:/usr/local/programX/bin:/usr/bin:/bin .RE .IP "2." 3 Filter any paths containing \f[I]/usr/local\f[R] .RS 4 .PP cleanpath -l /usr/local .PP /opt/special/bin:/usr/bin:/bin .RE .IP "3." 3 Filter any paths containing \f[I]special\f[R] and \f[I]local\f[R] .RS 4 .PP cleanpath -l special local .PP /usr/bin:/bin .RE .IP "4." 3 Filter only \f[I]/usr/local/programX/bin\f[R] using regular expressions .RS 4 .PP cleanpath -r `\[ha]/usr/local/p.*X/bin$' .PP /opt/special/bin:/usr/local/bin:/usr/bin:/bin .RE .SS Using different environment variables .IP "1." 3 Filter a named environment variable with custom separator .RS 4 .PP export TESTVAR=a:b/c:d/e:f .PP cleanpath -v TESTVAR -s / -l c .PP a:b/e:f .RE .SS Shell Scripting .PP PATH=\[lq]/usr/local/bin:/usr/bin:/bin\[rq] .PP PATH=\[lq]$(cleanpath -l /usr/local)\[rq]; export PATH .PP # /usr/local/bin has been filtered from PATH .SH ERRORS .PP \f[B]cleanpath\f[R] will exit non-zero (>0) when an error occurs. A value greater than one (1) indicates a fatal error. .SH BUGS .PP See GitHub Issues: .SH AUTHOR .PP Joseph Hunkeler .SH SEE ALSO .PP \f[B]re_format(7)\f[R]