I have an overnight script which runs across a large directory to repair permissions and ownership. I also have this command output the list of files affected so that cron can email these as a log file. Previously I had the command in the form:
As it is a long command sometimes I never receive a log email even though the ownership and permissions have changed, so I want to make the script more efficient. As such I have changed the command to:
Is there anything I can do to that command so that it sill lists the files on standard output so that they will be emailed by cron in addition to piping them to xargs?
I cannot include the -print action in the find command as this will also be piped to xargs. Likewise if I include an -exec action with an echo command. Also I do not want to use the -t option with xargs as I just want the list of files and not the chown commands it generates.
The best solution I have been able to come up with is to use tee to ssave output in a temporary file to display afterwards, but I am hoping there is better solution.
Thanks,
Michael.
Last edited by Franklin52; 06-19-2011 at 11:34 AM..
Reason: Please use code tags, when posting data and code samples, thank you
I have just tried that, and although it works, it is executing the commands individually for each file. Presumably this means it is not offering any performance advantage over that just using find's -exec action, if not less because of having to spawn the shell as well? The only reason for switching to use xargs was so that it can pass multiple files to chown reducing the number of times it would be called.
xargs work great when a command gives multiple line output which can be input to another. In my case it is not working coz the second command uses two words in it.
$ scr.sh
gives output like
193740
638102
375449
..
..
another command takes these number as inputs. it works great... (1 Reply)
I have been using unix on and off for a number of years. I am not a sys admin. I use what I need. I have googled this, but I really can't figure out what is the difference between using xarg and just using a regular pipe? Why do I need to include xarg sometimes and how do I know when I need it? (2 Replies)
Good afternoon,
I have just messed up and deleted some directories on my UNIX machine.
I would now want to know which packages are impacted by this. Therefore I have a look in the file "/var/sadm/install/contents" (which contains the filenames/directory names for each installation package). After... (2 Replies)
I have read several docs on these on the web and looked at examples. I can't figure out the difference. In some cases you use one or the other or you combine them.
can someone help me understand this? (1 Reply)
Hello,
I'm using csh. I have a file named "setup" that I normally source, e.g.
source setupI'd like a one-liner that sources this file, but excluding lines that contain "DEBUG", e.g.
cat setup | grep -v DEBUG | sourceOf course, the above does not work. How can I execute the results of a... (5 Replies)
I'm trying to get a count of all the files in a series of directories on a per directory basis. Directory structure is like (but with many more files):
/dir1/subdir1/file1.txt
/dir1/subdir1/file2.txt
/dir1/subdir2/file1.txt
/dir1/subdir2/file2.txt
/dir2/subdir1/file1.txt... (4 Replies)
I'm using the command grep -l XYZ to get a list of files containing the string XYZ. Then I using the comand ls -l ABC to get the create date timestamp of the each file. I've tried combining the comands using the pipe command, grep -l XYZ | ls -l, but its not working. What am I doing wrong? (3 Replies)
Hi,
On AIX 5200-07-00 I have a find command as following to delete files from a certain location that are more than 7 days old. I am being told that I cannot use -exec option to delete files from these directories.
Having said that I am more curious to know how this can be done.
an sample... (3 Replies)
What I'm trying to do is perform a copy, well a ditto actually, on the results of a find command, but some inline string substitution needs to happen.
So if I run this code find ./ -name "*.tif" I get back these results.
.//1234567.tif
.//abcdefg.tif
Now the action from exec or xargs I... (2 Replies)
ls -ltr | grep string
How can I use regular expressions to filter the results provided even more. I am using the above command as a reference. (1 Reply)