Results 1 to 7 of 7
-
12-11-2011, 02:29 PM #1
- Member Since
- Jul 13, 2011
- Posts
- 7
Repeating things in the terminal.Is there a way to repeat something 30 times in terminal?
-
12-11-2011, 03:21 PM #2
Loops are your friend. This following example will print Hello x where x is a number:
Code:for x in `seq 1 10` do echo Hello $x done
Code:Hello 1 Hello 2 Hello 3 Hello 4 Hello 5 Hello 6 Hello 7 Hello 8 Hello 9 Hello 10
Code:for x in `seq 1 30` do <your command> done
Save that as a shell script and simply execute it from the command line:Code:sh <path to script>
Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog
Writing a Quality Post
-
12-11-2011, 03:44 PM #3
how bout...
Code:#!/bin/bash x=1 while [ $x -le 30 ] do echo "Welcome $x times" x=$(( $x + 1 )) done
mike
This machine kills fascists
Got # ? phear the command line!
-
12-11-2011, 03:59 PM #4
As the Perl motto goes, "There's more than one way to do it."
For the OP: you can take my script (and Dysfunction's) and make it into a command instead of a script. Mine would look like so:Code:for x in `seq 1 30` ; do echo $x ; done
Important Links: Community Guidelines : Use the reputation system if you've been helped.
M-F Blog :: Write for the blog
Writing a Quality Post
-
12-11-2011, 08:45 PM #5
- Member Since
- Jul 13, 2011
- Posts
- 7
Would
Code:echo 'How many times?' read numtimes for x in numtimes do touch file $filenum.txt done
-
12-11-2011, 08:48 PM #6
- Member Since
- Jul 13, 2011
- Posts
- 7
ok, it does.(i tested it)
However, the file incrementing did not. How would i do this? I want to make as many files as possible.
-
12-11-2011, 09:02 PM #7
- Member Since
- Jul 13, 2011
- Posts
- 7
Ahhh, got it. That was confusing.
Code:#! /bin/bash echo "Ready to crash your computer?" read yes echo "You entered yes. Why?" mkdir ~/Desktop/Files cd ~/Desktop/Files echo 'How many times?' read x y=99 while [ $y -le $x ] do touch $y.txt y=$(( $y + 1 )) done
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Repeating Window that won't go away?
By Dale2012 in forum macOS - Operating SystemReplies: 3Last Post: 12-07-2014, 07:34 AM -
repeating emails
By Reedster in forum macOS - Apps and GamesReplies: 0Last Post: 05-19-2012, 01:09 PM -
Help setting up a vpn and repeating
By halimj7 in forum Internet, Networking, and WirelessReplies: 0Last Post: 07-22-2011, 03:35 PM -
URL name repeating itself using iweb
By norb123show in forum Web Design and HostingReplies: 1Last Post: 04-20-2011, 03:26 PM -
iCal repeating event
By Resoman in forum macOS - Apps and GamesReplies: 9Last Post: 12-02-2010, 08:24 PM