0

in which order are these bash commands executed ? is it possible that the fourth line starts before the first or the second one finish ?

find $LOCAL_TMP -type f -exec grep -l 'operationType="ACTIVATION"' {} ';' | xargs grep -l 'serviceCode="ACC-FTTS' | xargs -ICrTopoIpnatif mmv CrTopoIpnatif $LOCAL_TOPO

find $LOCAL_TMP -type f -exec grep -l 'operationType="DEACTIVATION"' {} ';' | xargs grep -l 'serviceCode="ACC-FTTS' | xargs -ICrTopoIpnatif mmv CrTopoIpnatif $LOCAL_TOPO

echo "mmv $LOCAL_TMP/**/*.xml $REP_LOCAL" >> $LOGFILE
mmv "$LOCAL_TMP/**/*.xml" "$REP_LOCAL" >> $LOGFILE

I am asking, because I found the files in $REP_LOCAL (which was a pool directory for another script, and the files show on the script's log), and not in $LOCAL_TOPO (nothing on the script's log here).

1
  • Do either of $LOCAL_TMP or $LOCAL_TOPO have an & character in them? Commented Dec 7, 2012 at 15:48

2 Answers 2

3

It's sequential. Everything happens in order. If you run the script with the following header

#!/bin/bash -x

then you'll see each command as it executes.

Sign up to request clarification or add additional context in comments.

Comments

2

As long as you execute all commands in the foreground, the commands are executed in the order you specify in the script.

command1
command2
command3

are executed one after the other.

Here

command1 &
command2
command3

command2 and command3 might finish before command1, if command1 needs more time to finish than the other two. This is because command1 and command2 and later command3 run in parallel, whereas in the first example all commands run in the foreground sequentially.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.