help with scrpit


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help with scrpit
# 1  
Old 04-28-2008
Tools help with scrpit

my friend has quized me.. I'm very new to scripts but I know I'm somewhat close

any help would be a major help..
here is the script

ex

shell program, hello, to display the phrase "hello world" 50 times (script should verify the

count) . Do not use a for loop! (hint should show hello world 1 ..... hello world 50 )

i put this

#!/bin/bash

count=1
max=50

while [ $count -le $max ] // a test of a condition -le another value
do
echo "Hello world $count"
let count=count+1

I still get a error.

any help would be nice thanks

airmax_sk@yahoo.com
# 2  
Old 04-28-2008
You were on the right track.
However your comment syntax was wrong & you needed to end the while loop with "done"...
Code:
#!/bin/bash

count=1
max=50

while [ $count -le $max ] ## a test of a condition -le another value
do
echo "Hello world $count"
let count=count+1
done

Cheers,
Cameron
# 3  
Old 04-28-2008
thanks

yah it gets a bunch of hellos out there


I must have forgot about the done command. no systex error.

i thought I put that on the command thanks for help cameron
# 4  
Old 04-29-2008
Hi,

Without using any loops you can get the same output. Just give a try on it.

Code:
yes "hello world" | head -50| grep -n "hello world" | awk -F: '{print $2" "$1}'

Regards,
Chella
# 5  
Old 04-29-2008
An awk trick:
Code:
awk 'BEGIN{$50=OFS="\nHello world";print}'|awk '!/^$/ {print $0,NR-1}'

# 6  
Old 04-29-2008
Neat trick Klashxx. Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

2 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

error when executing shell scrpit

Guys, when i am executing the following script I am getting following error. -bash: test.sh: command not found $ test.sh -- script name #! /bin/bash echo " Job started........" CURRENTDIR=`pwd` exit 0 thanks Please view this link: How to use ... tags (2 Replies)
Discussion started by: skatpally
2 Replies

2. Shell Programming and Scripting

using subsitiution in shell scrpit

I have a very (or so I thought) simple script I want to execute. The output should be 1 line of text from a web page called by lynx. #!/bin/bash cat urlList.txt while read line; do #echo $line output="$(lynx -dump -accept_all_cookies $line | sed -n '2p')" echo "$output" done I am... (3 Replies)
Discussion started by: roninuta
3 Replies
Login or Register to Ask a Question