Run text file as commands in Bash

0 votes

If I have a text file with a separate command on each line how would I make the terminal run each line as a command? I just don't want to have to copy and paste 1 line at a time. It doesn't HAVE to be a text file... It can be any kind of file that will work.

example.txt:

sudo command 1 sudo command 2 sudo command 3

Apr 13, 2022 in Linux Administration by Aditya
• 7,680 points
502 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Linux Administration

0 votes
1 answer

How to extract file base name without path and extension in bash?

You don't actually have to call the ...READ MORE

answered May 31, 2019 in Linux Administration by Shubham
• 13,490 points
5,501 views
0 votes
1 answer

Script file name in a Bash script

$0 will give you the complete basename. ...READ MORE

answered Jun 20, 2019 in Linux Administration by Shubham
• 13,490 points
551 views
0 votes
1 answer

Select sections of text from each line of files in a Bash shell.

Hi@akhtar, There is no inbuild command available for ...READ MORE

answered Oct 20, 2020 in Linux Administration by MD
• 95,440 points
723 views
0 votes
1 answer

How to find the first field from a file in Bash Shell?

Hi@akhtar, You can extract text from a file. ...READ MORE

answered Oct 20, 2020 in Linux Administration by MD
• 95,440 points
836 views
0 votes
0 answers

How to edit a text file in my terminal

I'm using Linux mint and using the ...READ MORE

Apr 25, 2022 in Linux Administration by Edureka
• 13,670 points
187 views
0 votes
1 answer

Is there a limit on the number of words in bash command 'for file in words'?

Anyway, you need to print everything except ...READ MORE

answered May 27, 2022 in Linux Administration by Korak
• 5,820 points
381 views
0 votes
1 answer
0 votes
1 answer

How do I set variable if a specific package version is installed in CFEngine?

Here is what you can do.Just use packagesmatching to ...READ MORE

answered Jul 12, 2018 in Other DevOps Questions by Atul
• 10,240 points
967 views
0 votes
2 answers

Install postgreSQL on Ubuntu

Follow the below commands to install PostgreSQL (PSQL) ...READ MORE

answered Nov 12, 2020 in Database by Prachi
• 140 points
939 views
0 votes
1 answer

Access progrs prompt without switching accounts

Use the following to get the postgres prompt ...READ MORE

answered Mar 22, 2019 in Database by Mahi
655 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP