"Command not found" doing a while loop in bash/shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting "Command not found" doing a while loop in bash/shell
# 1  
Old 02-25-2013
"Command not found" doing a while loop in bash/shell

Code:
i=0
numberofproducts=${#urls[@]}  #gets number of entries in array called "urls"
numberofproductsminusone=`expr $numberofproducts - 1`   #-subtract by one

while [$i -lt $numberofproducts]
do
	wget ${urls[$i]}
	 i=$(( $i + 1 ))
	sleep 10
done


I'm getting an error

./scrape: line 22: [0: command not found


that line corresponds with the "while" line.

Could anyone help me with this ? I googled but none of the examples I found were relevant to this.
# 2  
Old 02-25-2013
Put a space in between the square brackets and variables:
Code:
while [ $i -lt $numberofproducts ]

# 3  
Old 02-25-2013
Add a space between the [ and the $ on that line.

Regards,
Alister

---------- Post updated at 03:20 PM ---------- Previous update was at 03:18 PM ----------

Curse you, bipinajith!!! You beat me to the treasure yet again. I shall have my revenge!!! Just you wait. MWUAAHAHAHAHA. Smilie
# 4  
Old 02-25-2013
Quote:
Originally Posted by alister
Curse you, bipinajith!!! You beat me to the treasure yet again. I shall have my revenge!!! Just you wait. MWUAAHAHAHAHA. Smilie
Reminds me of Maximus Decimus Meridius in Gladiator... hahaha Smilie

Understanding the results: Indexed URL

Important notes:

Quote:
This is not a live test. This tool describes the most recently indexed version of a page, not the live version on the web. The information shown in the tool is used by Google to evaluate Search results. Your page may have changed or become unavailable since Google last saw it. To test the current version of the page as Google would see it, select the Live Test button on the page.
The "Last crawl" date under Index coverage, shows the date when the information shown here was retrieved (if the page was successfully crawled).
"URL is on Google" doesn't actually mean that your page is appearing in Search results. Actual appearance in Search results requires that the page and its structured data conform to quality and security guidelines. The URL Inspection tool doesn't take into account manual actions, content removals, or temporarily blocked URLs. To see if your URL is appearing, search for your URL on Google; if your URL is missing but this tool says it was indexed, here's how to find out why.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Query on using command "sed" for replacing text in bash shell

Re: Query on using command "SED" for replacing text in bash shell While using the command "sed" for find and replace, I wanted to know how one could find a constant and replace it with a variable inside the quotation syntax of sed? I wanted to replace constant 3 with variable name... (3 Replies)
Discussion started by: achandra81
3 Replies

2. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

3. UNIX and Linux Applications

Problem on SQLplus command ""bash: sqlplus: command not found""

Hi all, i face an error related to my server ""it's running server"" when i use sqlplus command $ sqlplus bash: sqlplus: command not found the data base is up and running i just need to access the sqlplus to import the dump file as a daily backup. i already check the directory... (4 Replies)
Discussion started by: clerck
4 Replies

4. Shell Programming and Scripting

Bash Script giving "Command Not found"

Hello Geeks, Greetings...I have the following script: #!/usr/bin/bash #Script to generate number of active PDP context & calculate PDP activation #failurefrom EPG-M #Script written by Gbenga Adigun #September 12, 2013 username="xxxxxx" password="xxxxxxxxx" HOSTS=( ggsn01... (6 Replies)
Discussion started by: infinitydon
6 Replies

5. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

6. UNIX for Dummies Questions & Answers

BASH: Interactive "cp" (and "mv") in a loop

Hi. I have a copy-file script (and a move-file script) that I recently tried to make interactive. I tested the former on three files from a text list, and watched to see what would happen. As the cp command was in a while/do/done loop, there was no pause for input: it wrote the file from the... (2 Replies)
Discussion started by: SilversleevesX
2 Replies

7. Post Here to Contact Site Administrators and Moderators

What's happens with my thread about "-bash: ELF: command not found "?

Hi, Today, I've submitted a new tread in "Shell Programming and Scripting" forum, with title "-bash: ELF: command not found ". However, this thread has disappear. Can somebody give me an explanation? Regards. (3 Replies)
Discussion started by: Sonia_
3 Replies

8. UNIX for Advanced & Expert Users

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

9. Shell Programming and Scripting

How to distinguish between "command not found" and "command with no result"

system() call imeplemented in solaris is such a way that: Command not found - return code 1 Command executed successfully without Output - return code 1 how to distinguish between these two based on return code in a c - file? Can you help on this ? (5 Replies)
Discussion started by: iitmadhu
5 Replies

10. Shell Programming and Scripting

"-bash: sqlldr: command not found"

hi all, here i am trying to run one control file. but getting "-bash: sqlldr: command not found" error :confused: the code is given below. sqlldr $db_username/$db_password@$db_sid control=$loading_path/load_to_table.ctl log=loading.log can anybody help me in fixing the issue? ... (1 Reply)
Discussion started by: vinayakatj56
1 Replies
Login or Register to Ask a Question