Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am running a command which does a quick checksum of some file like so

find / -type f -ctime +30 -mtime +30 -atime +30 -exec md5sum {} \; | xargs -P 4

and I am trying to run it in parallel with

xargs -P 4

Now, when I run the find command, by itself, I see output as each file is being checksummed. But when I pipe it to xargs, I no longer see the output of the find command.

Is there a way I could see the output of find when it is piped to another command?

share|improve this question

2 Answers 2

up vote 6 down vote accepted

You want this:

find / -type f -ctime +30 -mtime +30 -atime +30 -print0 | xargs -0 -P 4 md5sum

You want the list of files to be fedinto the md5sum command. This is done with find / | xargs md5sum. Then you want to not have to worry about crazy characters (spaces, newlines, whatever) in filenames, so we use -print0 for find and -0 for xargs.

share|improve this answer
    
thanks you very much for your answer this works :) –  user2840647 May 1 at 1:00

I took your command,

$ find / -type f -ctime +30 -mtime +30 -atime +30 -exec md5sum {} \; | xargs -P 4

And figured we want to redirect, while still echoing to stdout. One way we can do this is with tee

$ man tee | head
NAME
   tee - read from standard input and write to standard output and files

So, tee will definitely write to stdout (which is what we need to continue the chain), and also write to a file of our choosing. Great! But what file?

Thanks to this answer for the idea http://stackoverflow.com/a/9405342, we can use

/dev/tty

for our redirect, and it will print to our console!

So, for the full command:

$ find / -type f -ctime +30 -mtime +30 -atime +30 -exec md5sum {} \; | tee /dev/tty | xargs -P 4

I start seeing some great text roll down the screen as I do that :)

share|improve this answer
    
I like your answer because I wouldn't have thought of using tee to output it to /dev/tty. Thank you very much –  user2840647 May 1 at 1:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.