-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathifind.1
196 lines (158 loc) · 5.08 KB
/
ifind.1
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
.TH IFIND "1" "2018-04-25" "iRODS find utility" "User Commands"
.SH NAME
ifind \- iRODS find utility
.SH SYNOPSYS
.B ifind
.B [ \-h ]
.B [ \-C\ \fIconnection\fR ]
.B [ \-D ]
.B [ \-E\ \fIresource\fR ]
.B [ \-Q\ \fIsqlstatement\fR ]
.B [ \-R\ fIn,w,m\fR ]
.B [ \-X\ \fIregexp\fR ]
.B [ \-Y\ \fIsubst\fR ]
.B [ \-b\ \fIbatchsize\fR ]
.B [ \-c\ \fIcommand\fR ]
.B [ \-d\ \fIlevel\fR ]
.B [ \-f ]
.B [ \-l\ \fIlength\fR ]
.B [ \-n\ \fIn\fR ]
.B [ \-p\ \fIn\fR ]
.B [ \-q ]
.B [ \-s\ \fItype\fR ]
.B [ \-S ]
.B [ \-v ]
.B \fIcollection\fR
.SH DESCRIPTION
This utility is a bit similar to the traditional \fIfind\fR
command in Unix.
It scans a directory tree and executes a command for each
file passing the file/directory name as an argument.
To list the directory tree it directly connects to the Postgres
database with the metadata so it's best to be used on the
icat host though it can take any connect string to connect
to a remote Postgres database. It is Postgres specific. It uses
cursors so it retrieves the results in batches, how many rows
to return in a batch is adjustable. It can be directed to scan
only directories or files, the full pathname is returned in
every case. The output can be sorted, reverse sort for directories
produces a canonical order traverse list finishing with the top level.
.TP
.B \-h\fR
to print this help.
.TP
.B \-C \fIconnection\fR
Postgres connect string to identify the database to connect to.
Use quotes when it contains spaces.
.TP
.B \-D\fR
Print directory names (collections) only. The default is to print file names.
.TP
.B \-E \fIresource\fR
Resource name to select.
.TP
.B \-I\fR
Also print file IDs.
.TP
.B \-Q \fIsqlstatement\fR
Execute a Postgresql statement for every file or collection,
replacing the token
.B %llu
with the ID of the object. The statement
string will contain spaces so it must be quoted.
.TP
.B \-R \fIn,w,m\fR
Retry failed command \fIn\fR times after waiting for \fIw\fR seconds,
allowed \fIm\fR max tries all in all.
.TP
.B \-X \fIregexp\fR
Select files or directories with matching POSIX regexp pattern.
.TP
.B \-Y \fIregexp\fR
Substitute regexp match with this string.
.TP
.B \-b \fIbatchsize\fR
the number of rows to retrieve from the metadata database in one batch.
The default is 1024.
.TP
.B \-c \fIcommand\fR
is the command to execute for each file/directory.
The absolute pathname will be appended in single quotes.
Alternatively a printf string with '%s' markers can be
supplied, in which case the markers will be replaced with
the pathname, just like with printf. Only four of these can
be specified. It is best to supply this string using single
quotes around the %s since it might contain spaces.
The default is to print the full pathname, in this case
multitasking is not allowed since it would result in garbled
output.
.TP
.B \-d \fIlevel\fR
is the debug level, larger number for more details.
The default is no debug, if this switch is omitted.
.TP
.B \-f\fR
Force, continue even when the command returns non-zero status.
.TP
.B \-l \fIlength\fR
Report files with pathname longer then this number.
Do not specify this together with -X or -Y.
.TP
.B \-n \fIn\fR
This option specifies multitasking, n tasks will be forked in
parallel, each to process one batch as moving forward. Please note
that in this case the output with pathnames will be garbled and not
suitable for further processing since the all the processes are writing
the same time.
.TP
.B \-p \fIn\fR
progress indicator, print a dot for every \fIn\fR database fetch as processed.
One fetch returns \fIbatchsize\fR records, sometimes less at the end so it is
approximate.
.TP
.B \-q\fR
Quiet.
.TP
.B \-r \fIn\fR
Replica number. The default is all replicas.
.TP
.B \-s \fItype\fR
Sort type, 0 for no sort, 1 for ascending, 2 for descending,
3 for ascending unique, 4 for descending unique. (Note that
files with replicas are returned as multiple rows.)
.TP
.B \-S\fR
Print summary at the end. The transfer speed numbers can be
meaningless in case the executed command deals only with
metadata and not doing any actual data movement.
.TP
.B \-t\fR
Test, print command string but don't execute.
.TP
.B \-u \fIlocale\fR
Check pathnames if they confirm to UTF-8 or other locale, as specified.
The locale name is the one like en_US.UTF8 as per the Posix specification.
.TP
.B \-v\fR
Verbose. Print the names.
.TP
.B \fIcollection\fR
is a collection/directory to use as root of the tree. It should be
absolute pathname.
.SH EXAMPLES
.B ifind -v /snic.se/home
will list all files under the specified directory.
.B ifind -c 'ils -L' /snic.se/home
to create a full attribute list of all files.
The command
.B ifind -D -v -s 2 /snic.se/home
will list all directories under home in reverse canonical order,
finishing with the top level directory. This is suitable for example
to delete a directory tree.
To rename all files in a directory tree to have a prefix x_ you can use
the command
.B ifind -c \(dqimv '%s' 'x_%s'\(dq /snic.se/home/user00
It might be a good idea to single quote the file names in case they include
spaces.
Note that quotes in file names are not allowed and will cause an error
message to be displayed.