The entire purpose of running a job asynchronously is to allow you to run other jobs at the same time. If you don't want to run any other jobs at the same time while your find command is running; don't run it asynchronously.
The two commands:
produce exactly the same output that the single command:
does, but takes fewer keystrokes and makes less busywork for the shell. The first two commands force the shell to create a subshell to run find asynchronously; the last command is run in the current shell execution environment without the need to create a subshell environment. The first two commands slow down your system for you and other users on your system.
Note also that every time this script runs, it creates a new temporary file and (from what you have shown us) never uses anything written into it and never removes it. And the name you are using for that temporary file (with three random numbers included in the name and with two of those random numbers adjacent to each other with no separator) increases the chance that two different invocations of your script will accidentally come up with the same name. If that happens, find will never be run for this invocation of your script.
And, there is no need to create three subshells to include those three random numbers in the name. The command:
produces exactly the same temporary filename as your current code does but avoids creating three unneeded subshells to set the name.
A more common way to do this (since there can never be two shells running with the same process ID) is to use:
to lessen the chance of a collision with your various multiple adjacent uses of $RANDOM. Of course, we might also comment that as far as we can tell from what you have shown us, $CURRENT_USER will expand to an empty string because it has never been set to anything else. And, since we have no idea how, or if, CURRENT_USER has been set, any expansion of tot_files_found when field splitting might occur should be included in a double-quoted string.
From everything that you have said about what you are trying to do, I do not understand why you have a loop at all? The following would seem to be a better fit for your stated goals (which I still do not understand):
But, as has been said before, having yad as the second process in a pipeline when the first process in that pipeline will NEVER write anything into that pipe is not a "normal" way to do things. Whatever output yad produces has nothing to do with whether or not find is making any progress; all it can tell us is when find has terminated. And that could be done more simply with:
We should probably also include a trap to remove the temporary file created by this script, but I haven't yet figured out if there might be some reason why you would want to actually know how many files were found instead of just wasting time figuring out how many there are and then exiting without ever looking at the results.
Last edited by Don Cragun; 03-29-2019 at 01:45 AM..
Reason: Fix mismatched parenthesis.
This User Gave Thanks to Don Cragun For This Post:
Hi All,
I need to pass a variable to perl script from bash script, where in perl i am using if condition. Here is the cmd what i am using in perl
FROM_DATE="06/05/2008"
TO_DATE="07/05/2008"
"perl -ne ' print if ( $_ >="$FROM_DATE" && $_ <= "$TO_DATE" ) ' filename"
filename has... (10 Replies)
Hi,
I use AIX (ksh) and Linux (bash) servers. I'm trying to do scripts to will run in both ksh and bash, and most of the time it works. But this time I don't get it in bash (I'm more familar in ksh).
The goal of my script if to read a "config file" (like "ini" file), and make various report.... (2 Replies)
Hello all,
I'm working on a script, and as part of it, I'm trying to create a loop that will run through a stored piece of information a certain number of times pulling out information, and each time create a variable with a unique name that will store that information. I'm sure it's a simple... (3 Replies)
Hello all,
I have this shell script, but do not understand why the variables inside the if block does not keep its value outside. Is it because of the pipe ? How can i fix this problem ?
Thank you for helping.
local alarm=""
local num_alarm=0
local -a alarms
... (3 Replies)
Hello,
I am struggling with using variable made using "eval".
a=4
eval b$a=20
echo $b$a ???
As shown above, I am trying to call back the variable "bX" assuming I do not know the value of "a".
How can I do that?
I tried several combinations but nothing worked.
Thanks (10 Replies)
Hi,
I wrote the following program to understand mutexes. If I run the program , number of threads is shown as zero, even after creating one thread. When running with gdb, it works fine.
The function process is used to update global variable (used to keep track of threads). It looks like the... (2 Replies)
#aa=xxxx
#zz="cc $aa"
#aa=gggg
#echo $zz
out put is
cc xxxx
if I want to get
cc gggg
how should I do, I don't want to write zz="c $aa " after aa=gggg (2 Replies)
Hello,
Can I ask how to expand variable that contains another in bash? I need to loop variable within another one like this:
RD1=testgrp
RD2=testgroup
RD3=testgroupfile
RD4=tstgroup
...
RD40=try2013
DEST=/home/king/finaldir
for i in {1..40}; do
mv ${RD${i}} ${DEST}
done
I do not... (8 Replies)
Hi Team
In the below code, irrespective of the if statement that gets executed, retcd is being assigned a standard value(1) instead of changing as per code. Could you please help to see where is it going wrong.
rval=0
CONF_FILE=/apps/wmroot/scripts/props/UMPath.properties
NOHUP="nohup"... (3 Replies)