You would have to run this as root, but:
for user in $(cut -f1 -d: /etc/passwd); do crontab -u $user -l; done
will loop over each user name listing out their crontab. The crontabs are owned by the respective users so you won't be able to see another user's crontab w/o being them or root.
Edit
if you want to know which user a crontab belongs to, use echo $user
for user in $(cut -f1 -d: /etc/passwd); do echo $user; crontab -u $user -l; done
Use the shell globbing syntax:
grep pattern -r --include=\*.cpp --include=\*.h rootdir
The syntax for --exclude
is identical.
Note that the star is escaped with a backslash to prevent it from being expanded by the shell (quoting it, such as --include="*.cpp"
, would work just as well). Otherwise, if you had any files in the current working directory that matched the pattern, the command line would expand to something like grep pattern -r --include=foo.cpp --include=bar.cpp rootdir
, which would only search files named foo.cpp
and bar.cpp
, which is quite likely not what you wanted.
Update 2021-03-04
I've edited the original answer to remove the use of brace expansion, which is a feature provided by several shells such as Bash and zsh to simplify patterns like this; but note that brace expansion is not POSIX shell-compliant.
The original example was:
grep pattern -r --include=\*.{cpp,h} rootdir
to search through all .cpp
and .h
files rooted in the directory rootdir
.
Best Answer
Piping to another process (Although this WON'T accomplish what you said you are trying to do):
This will send the output of command1 as the input of command2
-exec
on afind
(this will do what you are wanting to do -- but is specific tofind
)(Everything between
find
and-exec
are the find predicates you were already using.{}
will substitute the particular file you found into the command (cat {}
in this case); the\;
is to end the-exec
command.)send output of one process as command line arguments to another process
for example:
(Note these are BACK-QUOTES not regular quotes (under the tilde ~ on my keyboard).) This will send the output of
command1
intocommand2
as command line arguments. Note that file names containing spaces (newlines, etc) will be broken into separate arguments, though.