Use results of a command as input for another command bash/Linux, or how to find files and move them

For example, find all files of a certain type and move them to a directory.

The first command is

find . -name "*.tif*"

To use the results of that command in mv, place the command inside parentheses and put a dollar sign at the beginning.

mv $(find . -name "*.tif*") tif/

Now, every file path output by the find command will be run through mv. This will repeat for every line output by find (i.e. every file)

Set logwatch to run weekly instead of daily

Move /etc/cron.daily/00logwatch to /etc/cron.weekly/

In /etc/logwatch/conf/logwatch.conf, change Range = yesterday to Range = between -7 days and -1 days

The above date range selection requires a Perl library that should already be installed on your system (it is on Ubuntu 16.04)

If logwatch doesn’t work after making this change, run apt-get install libdate-manip-perl

Blog at

Up ↑