LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-01-2023, 12:02 PM   #1
atjurhs
Member
 
Registered: Aug 2012
Posts: 316

Rep: Reputation: Disabled
how do i sequentially run multiple awk/bash scripts


hi guys,

i have several bash scripts that each call awk.

from the command line, instead of doing

./script1.awk
./script2.awk
./script3.awk


i would like to do something like

./(script1.awk script2.awk script3.awk)

that of course doesn't work, but how can i do this?
 
Old 02-01-2023, 12:14 PM   #2
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
One easy way would be to chain the commands like
Code:
./script1.awk ; ./script2.awk ; ./script3.awk

or 

./script1.awk && ./script2.awk && ./script3.awk
That could be done even easier if you wrote another script to call each of those one after the other.
I would also suggest that you add the full path to each script and possibly even some cd steps in there so you ensure the scripts are being performed in the proper location.
 
3 members found this post helpful.
Old 02-01-2023, 12:16 PM   #3
atjurhs
Member
 
Registered: Aug 2012
Posts: 316

Original Poster
Rep: Reputation: Disabled
yep, i think i figured it out as you were typing

sorry to waste your digits
 
Old 02-01-2023, 12:18 PM   #4
jayjwa
Member
 
Registered: Jul 2003
Location: NY
Distribution: Slackware, Termux
Posts: 805

Rep: Reputation: 257Reputation: 257Reputation: 257
for loops. Bash/Zsh, possibly others:

Code:
for scripts in $( seq 1 3 ); do
  ./script${scripts}.sh
done
 
1 members found this post helpful.
Old 02-01-2023, 03:31 PM   #5
khbkhb
LQ Newbie
 
Registered: Jun 2008
Posts: 2

Rep: Reputation: 1
you might want to think about stopping the sequence if any of them fail. See the FM about && operator.
Or more wordy, but allowing for greater flexibility the if ! $script ; then ; fi construct.
 
1 members found this post helpful.
Old 02-02-2023, 04:26 AM   #6
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,845

Rep: Reputation: 1222Reputation: 1222Reputation: 1222Reputation: 1222Reputation: 1222Reputation: 1222Reputation: 1222Reputation: 1222Reputation: 1222
That is what the
Code:
./script1.awk && ./script2.awk && ./script3.awk
does.
In contrast to a semicolon the && only continues if the exit status is good.
In a loop you would use a break statement:
Code:
for scripts in 1 2 3; do
  ./script${scripts}.sh || break
done
The || runs the following statement if the exit status is bad.

Last edited by MadeInGermany; 02-02-2023 at 04:30 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] processing 9 scripts sequentially or combing them into one atjurhs Linux - Newbie 29 05-09-2022 09:48 AM
[SOLVED] Bash script to run sequentially dpynn Linux - Software 11 02-27-2012 07:51 AM
get several scripts to run sequentially feffer777 Programming 9 04-16-2011 08:55 PM
how to write a shell script for submitting multiple jobs sequentially cliffyao Programming 4 05-27-2010 02:44 PM
mulitple copy a existing directory and rename it at the end sequentially in BASH neo2k Linux - Newbie 2 08-20-2008 10:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration