Loop

Forum rules
Before you post please read how to get help
User avatar
mrmajik45
Level 4
Level 4
Posts: 210
Joined: Tue Aug 29, 2017 9:51 pm
Location: USA, indiana
Contact:

Loop

Postby mrmajik45 » Sat Nov 11, 2017 1:49 pm

Code: Select all

while true; do echo -n "Mrmajik45 "; done

Replace mrmajik45 with whatever you want it to say.
The linux coder.
Image

User avatar
xenopeek
Level 24
Level 24
Posts: 21381
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: Loop

Postby xenopeek » Sat Nov 11, 2017 1:52 pm

Let's optimize that! This command does the exact same thing :wink:
yes Mrmajik45

Ctrl+C to interrupt the command.
Image

User avatar
mrmajik45
Level 4
Level 4
Posts: 210
Joined: Tue Aug 29, 2017 9:51 pm
Location: USA, indiana
Contact:

Re: Loop

Postby mrmajik45 » Sat Nov 11, 2017 2:31 pm

That could be the Straight line version.
The linux coder.
Image

User avatar
xenopeek
Level 24
Level 24
Posts: 21381
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: Loop

Postby xenopeek » Sat Nov 11, 2017 3:00 pm

Ah, I missed the -n on your echo.

To turn the newlines into spaces we can do something like:
yes Mrmajik45 | tr $'\n' ' '
Or:
yes Mrmajik45 | paste -sd ' '

Not as neat :)
Image


Return to “Scripts & Bash”