summary refs log tree commit diff
path: root/rwc.1
blob: 6a84deefc1a56609e54e85a0a61d359b90655674 (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
.Dd March 3, 2019
.Dt RWC 1
.Os
.Sh NAME
.Nm rwc
.Nd report when changed
.Sh SYNOPSIS
.Nm
.Op Fl 0cdep
.Op Ar path\ ...
.Sh DESCRIPTION
.Nm
takes a list of files or directories, watches them using
.Xr inotify 7 ,
and prints each file name when it changed.
If
.Ar path
is a single dash
.Pq Sq -
or absent,
.Nm
reads file names from the standard input.
.Pp
Watching a directory will result in watching all changes to files
which resides directly in that directory.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl 0
Read input filenames seperated by NUL bytes.
Likewise, output filenames seperated by NUL bytes.
.It Fl c
Detect all file creations, including
.Xr open 2
with
.Dv O_CREAT ,
.Xr mkdir 2 ,
.Xr link 2 ,
.Xr symlink 2 ,
and
.Xr bind 2 .
In this case, created files are prefixed by
.Sq Li "+ "
(that is, a plus and a space).
This option has the side-effect of printing files twice
that are created and immediately changed after.
.It Fl d
Also detect file deletion.
In this case, deleted files are prefixed by
.Sq Li "- "
(that is, a dash and a space).
.It Fl e
Exit after the first reported change.
.It Fl p
Pipe mode;
don't report changes while the standard output pipe is not empty.
Use this to pipe
.Nm
to programs which read standard input slowly.
.El
.Sh EXIT STATUS
.Ex -std
.Sh EXAMPLES
Watch all source files and run
.Xr make 1
when something changes:
.Pp
.Dl % git ls-files | rwc -p | xe -v -s make
.Pp
Make a sound when a download is done:
.Pp
.Dl % rwc ~/Downloads | xe -s 'mpv ~/.sounds/bing.wav'
.Sh SEE ALSO
.Xr entr 1 ,
.Xr inotifywatch 1 ,
.Xr wendy 1
.Sh AUTHORS
.An Leah Neukirchen Aq Mt leah@vuxu.org
.Sh CAVEATS
.Nm
is limited by some restrictions of
.Xr inotify 7 .
You can only watch files and directories you can read,
and the amount of inotify descriptors is limited.
Watching directories is not recursive.
.Pp
.Nm
only uses one watch descriptor per directory,
and filters file names itself.
This allows tracking files which get safely written by
.Xr unlink 2
and
.Xr rename 2 ,
and also watching files which don't exist yet.
.Pp
Many tools like to create temporary files in their working directory,
which may distort the output.
.Sh LICENSE
.Nm
is in the public domain.
.Pp
To the extent possible under law,
the creator of this work
has waived all copyright and related or
neighboring rights to this work.
.Pp
.Lk http://creativecommons.org/publicdomain/zero/1.0/