What does this shell script do? Need in depth explanation please


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting What does this shell script do? Need in depth explanation please
# 1  
Old 09-25-2016
What does this shell script do? Need in depth explanation please

Hi

My friend wrote this particular script and won't tell me what it does, and when I run it I don't understand it.

What does the entire script do with specifics please.

Thanks
Bob

Code:
#!/bin/bash
current=0
while [ $SECONDS -le 10 ]; do
if [ $SECONDS -eq ${current} ]; then
echo ${current}
current=$((${current}+1))
fi
done


Last edited by Don Cragun; 09-25-2016 at 11:44 PM.. Reason: Add CODE tags.
# 2  
Old 09-25-2016
Is this a homework assignment? Homework and coursework questions can only be posted in the Homework & Coursework forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

If you did post homework in the main forums, please review the guidelines for posting homework and repost. If this is not a homework assignment, please explain where you found this code and what it is being used for.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script explanation

Hey, can someone explain me this script? i=0 while read WORT do echo $WORT|grep a>/dev/null || echo$WORT|grep B>dev/null || let i=$i+1 done echo $i The first lane initializie the variable i with the value of 0. The loop line has 3 different options because of ||. The only option I... (10 Replies)
Discussion started by: newuser21
10 Replies

2. Shell Programming and Scripting

How to write Perl Script to Get MQ Queue Depth?

Hi , I got the following script from internet to display queue depth using Perl Script. However, when I execute it , im getting following error. Can anyone shed light on what is going wrong? #!/usr/bin/perl ## 07/23/01 ## Depth Inquiry sample program. ## Arguments: ## Connects to... (11 Replies)
Discussion started by: srkmish
11 Replies

3. Solaris

Explanation of script

Hello Guys, can someone help explain the script below for me? I will really appreciate it. vi db_script #!/bin/sh echo .cron job run on.`date`> cronjob.txt df -h >> cronjob.txt echo welcome to home (2 Replies)
Discussion started by: cjashu
2 Replies

4. Shell Programming and Scripting

need an explanation on this script...

The following script will create a directory in a directory and will go on as many times as the number you will give in. I am trying to find out how it works ... can someone please help me with that? #!/bin/sh #create a variable and set it to 1 n=1 #start a loop as... (3 Replies)
Discussion started by: I-1
3 Replies

5. Shell Programming and Scripting

Script explanation

#script fileused=test.txt hostname=test.dis.com ftp $hostname <<-! > $fileused.err 2>&1 put file.txt /usr/text.txt bye ! kindly the above script the one marked as Bold and underlined as the above i am declaring the new variable as filename ,But when i used i had used as $fileused.err... (1 Reply)
Discussion started by: rajar_r
1 Replies

6. Shell Programming and Scripting

Shell Script Explanation

Hello, I have seen this script on this site. I understand most of it. However I am a bit stuck on the part in red. It appears to be expanding for file in *.zip do zipdir=${file%.*} mkdir $zipdir || echo "unable to create $zipdir" cp $file $zipdir || echo "unable to copy $file"... (3 Replies)
Discussion started by: jaysunn
3 Replies

7. Shell Programming and Scripting

explanation for a script

Guys, was wondering what the meaning of the below bit is ? awk -F ' ' '{print $1 " " $2 ;}' $TEMPFILE | (rm -f $TEMPFILE; sed 's/$/ '"$box"'/g' > $TEMPFILE) Can anyone explain this in detail? what is the significance of rm -f $TEMPFILE here? What all IO/buffering happens here ?How the... (0 Replies)
Discussion started by: hashin_p
0 Replies

8. Shell Programming and Scripting

Need explanation of script

Hi All, Can anybody explain what this script is doing? #!/bin/sh who | cut -d " " -f1 | sort -u > userlist1 while true ; do sleep 60 who | cut -d" " -f1 | sort -u >userlist2 for username in `cat userlist1` ; do if ! grep "^$username$" userlist2 > /dev/null ; then echo... (0 Replies)
Discussion started by: vishalpatel03
0 Replies

9. Shell Programming and Scripting

Script explanation

I have the following script awk '$1 ~ /^*+/ { s += $NF; m++ } END { print NR, m, s } and I use it to get results from the following file A4792 4 COMP9021 5 K9 7 ABC 8 924 1 R2D2 3 (8 Replies)
Discussion started by: sickboy
8 Replies

10. Shell Programming and Scripting

any explanation for thsi shell script behaviour

hello whats the difference between excuting a shell script as a)sh myscript.sh b). ./myscript.sh i noticed that my shell script works fine when i run it as . ./myscript .sh but fails when i run it as sh myscript.sh could anybody explain why. the shell script is very simple ... (9 Replies)
Discussion started by: xiamin
9 Replies
Login or Register to Ask a Question