aboutsummaryrefslogtreecommitdiff
path: root/docs/man/cleanpath.1
blob: ba3db6334a1652deb2df5fdd5b52263f3ff2c74d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
.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]--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: <https://github.com/jhunkeler/cleanpath/issues>
.SH AUTHOR
.PP
Joseph Hunkeler <jhunkeler\[at]gmail.com, jhunk\[at]stsci.edu>
.SH SEE ALSO
.PP
\f[B]re_format(7)\f[R]