I wrote a simple python script that outputs a bunch of linux commands for a custom image manipulation command-line tool.
As an example, here is what the python script creates:
img_dae_create /d /t /19 "file1.jpg" -output "heavy" -t /mnt/img/output/
img_dae_create /d /t /7 "file2.jpg" -output "light" -t /mnt/img/output/
img_dae_create /d /t /8 "file3.jpg" -output "ex" -t /mnt/img/output/
Normally, I just copy and paste them to my Ubuntu command line and run one by one. Each command can take from 1 minute to 15+ minutes to execute.
But sometimes, the python script will generate 100s of these, and it is very tedious to copy and paste each one.
So I was wondering what would be the best command line operator to use in this case?
Would ;
be better than &&
given that:
The time it takes for each command to run could be between 1 and 15 minutes.
The outcome of the command does not matter, if it fails, then the command line tool records that in a log file and can be dealt with later.
Thanks!
&&
between the commands. But for 100s of them you might want to look into making a bash script or at least split them up into smaller chunks. – totalynotanoob Oct 20 '20 at 17:40&&
is for typing directly into the terminal. bash scripts have a different structure because they are made for completing multiple commands in a row. you should look up some tutorials to learn the syntax and structure before trying it out. – totalynotanoob Oct 20 '20 at 17:49&&
versus separating the commands over multiple lines (or using;
) is not about command line versus script - it's about the desired logic. See for example What are the shell's control and redirection operators? – steeldriver Oct 20 '20 at 18:11command1 ; command2 ; command3;
would be best right? Because I need for one command to finish before a new one is started. I also don't care about outcome, like if it fails or not, because that is recorded by the actual command-line utility that I am using – SkyeBoniwell Oct 20 '20 at 18:59cat | while read -r; do /path/to/$REPLY; done
even change the output from the python to JSON andcat | jq | while ...
that would give him some control – Oct 20 '20 at 21:49