[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 513
  • Last Modified:

How to use WAIT in a bash file

Experts,

          I have a bash file that runs through and does all the steps I want it to. However, it moves some files and while the files are being moved the script goes back to the command prompt and it looks like nothing is happening with the script. How do I get it to wait until the files are moved then go on to the next step?
0
missymadi
Asked:
missymadi
  • 2
2 Solutions
 
farzanjCommented:
You can make it a background job like this:

commands that take time &
Then get the Process ID by doing

pid=$!

wait $pid
0
 
wesly_chenCommented:
In the script, run the commands in sequence

...
mv <source file> <target file>  (don't put it to background with &)
<next command>
...
0
 
farzanjCommented:
If you show the script, it would be easier to comment about it.
0
 
TintinCommented:
Simply don't run the move in the background.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now