Script to monitor progress of find/exec command


 
Thread Tools Search this Thread
Top Forums Programming Script to monitor progress of find/exec command
# 1  
Old 09-28-2017
Script to monitor progress of find/exec command

hi all,

i want to monitor the progress of a find and exec command, this is the code i use -

Code:
find . -type f -exec md5sum {} \; >> /md5sums/file.txt

this command works and produces a text file with all the md5sums but while running it doesnt show the progress

is there anyway i can do this

many thanks,

rob
# 2  
Old 09-28-2017
You could try changing it to drive a loop, something like this:-
Code:
while read file
do
   printf "$file\n" >&2
   md5sum "$file"
done < <(find . -type f) >> /md5sums/file.txt

That should write to STDERR and not get captured in the output file. Can I just ask, do you mean to append to your output file? The output could be a complete overwrite because it should be the output from the find command, not each individual md5sum.



I hope that this helps,
Robin

Last edited by rbatte1; 09-28-2017 at 08:55 AM.. Reason: Replaced suggestion because an extra -exec clause didn't work.
# 3  
Old 09-28-2017
sorry your right i dont want to append so i will be using
Code:
>

# 4  
Old 09-28-2017
Does the suggestion do what you want?

Another might be to use xargs similar to this:-
Code:
find . -type f | xargs -tn1 md5sum > /md5sums/file.txt

The flags are:-
  • -t - write the arguments to STDERR for each run of the command named
  • -n - limit the number of arguments, in our case to 1 so we see each file click through


Do either of these work for you?


Robin
These 3 Users Gave Thanks to rbatte1 For This Post:
# 5  
Old 10-04-2017
thanks rbatte1, i will try xargs
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Linux find command seems to not transmit all the result to the '-exec command'

Hello. From a script, a command for a test is use : find /home/user_install -maxdepth 1 -type f -newer /tmp/000_skel_file_deb ! -newer /tmp/000_skel_file_end -name '.bashrc' -o -name '.profile' -o -name '.gtkrc-2.0' -o -name '.i18n' -o -name '.inputrc' Tha command... (3 Replies)
Discussion started by: jcdole
3 Replies

2. Programming

Bash script - find command with delete and exec

hi all, i have devised a script that starts in /restored/ and in there, there are a lot of sub folders called peoples names and in the sub folders are files/folders and it deletes the data in the sub folders BUT not the sub folder itself and it should then touch a file in all the sub folders... (3 Replies)
Discussion started by: robertkwild
3 Replies

3. Shell Programming and Scripting

Find and move command with exec

Hi all, I am trying to find files newer than a given file and them mv them to a new location. So I far I have: find . ! -newer <file_name> -exec ls -l {} \; and find . ! -newer <file_name> -exec mv /TEMP_LOCATION {} \; find is not liking this. Anyone know how to modify the last... (2 Replies)
Discussion started by: jonnyd
2 Replies

4. UNIX for Dummies Questions & Answers

What does the '\' in find -exec command

Hi, I have two scripts that remove files. One works fine and is coded find -name "syst*" -mtime +1 -exec rm {} \; The other is almost the same - only thing missing is the '\'. On that script though I keep getting: rm syst1202.file ? etc Does the \ make that difference or is it a... (3 Replies)
Discussion started by: Grueben
3 Replies

5. Shell Programming and Scripting

find command with -exec

Hi all, Please could someone help with the following command requirement. I basically need to find files NEWER than a given file and order the result on time. My attempt so far is as follows: find . -newer <file_name> -exec ls -lrt {} ;\ But I dont seem to get the right result... (12 Replies)
Discussion started by: jonnyd
12 Replies

6. Shell Programming and Scripting

find command with -exec

Hi People, I have a directory full of compressed files (.Z extention) In many of these files there is a string pattern (3800078163033) I want to find all file names which contain this string in their text. Regards, Abhishek (2 Replies)
Discussion started by: max29583
2 Replies

7. UNIX for Advanced & Expert Users

Find command with prune and exec

Hi, I'm using the following command to get a list of files on the system. find /releases -type f -exec ls -l > /home/sebarry/list.txt '{}' \; however, its searching a directory I don't want it to search so I know I have to use prune but I don't seem to be able to get prune and exec to work... (1 Reply)
Discussion started by: Sebarry
1 Replies

8. UNIX for Dummies Questions & Answers

find command exec error

Hi All, i am writing a shell script in korn shell which deletes all the files in a directory once in every 10DAYS. the directory has different format files. the script has something like this; cd /home/data/pavi echo "Please Enter the Number of Days to search for" read DAYS... (2 Replies)
Discussion started by: pavan_test
2 Replies

9. Programming

Monitor a progress bar using separate threads

I need to look at sample codes or programs that monitor a task using separate threads in Unix and C. (0 Replies)
Discussion started by: ryphelon
0 Replies
Login or Register to Ask a Question