LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-16-2013, 09:37 PM   #1
fajarpri
LQ Newbie
 
Registered: May 2005
Posts: 9

Rep: Reputation: 0
Bash: repeating command


Hi all,
I have this bash script. How do I make it to repeat like 50 times with 1 second delay in between? Thanks in advance
Code:
#!/bin/bash
pdbedit -z -u $1
pdbedit -c "[]" $1
pdbedit -Lv $1
 
Old 07-16-2013, 09:44 PM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,340

Rep: Reputation: Disabled
for loops can be used to repeat a command or a set of commands any number of times. The sleep command is used to introduce a delay.
 
1 members found this post helpful.
Old 07-16-2013, 09:45 PM   #3
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

Quote:
Originally Posted by fajarpri View Post
Hi all,
I have this bash script. How do I make it to repeat like 50 times with 1 second delay in between? Thanks in advance
Code:
#!/bin/bash
pdbedit -z -u $1
pdbedit -c "[]" $1
pdbedit -Lv $1
You should look up how to use loops in bash scripts, and also investigate the sleep command. Entering "bash for loop" into your favourite search engine, and "man sleep" into your terminal should provide the information you need.

HTH,

Evo2.
 
1 members found this post helpful.
Old 07-16-2013, 10:03 PM   #4
fajarpri
LQ Newbie
 
Registered: May 2005
Posts: 9

Original Poster
Rep: Reputation: 0
Thank you!
Got help from Goldfish at bash IRC.

#!/bin/bash
for i in {1..50}
do
pdbedit -z -u "$1"
pdbedit -c "[]" "$1"
pdbedit -Lv "$1"
sleep 1
done
 
  


Reply

Tags
bash



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Repeating the command after one execution rajesh1978 Linux - Newbie 6 10-13-2010 10:41 PM
repeating command monu Linux - General 3 10-20-2007 06:18 PM
repeating the command ekdya Debian 2 03-31-2006 04:47 PM
Bash Script, Repeating Data t0bbage Linux - General 5 07-09-2005 01:30 AM
traceroute command AND repeating the destination in output dan99 Linux - Networking 1 01-22-2005 10:00 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:47 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