linux - For loop finding more files than it should -


I have the following for a loop in a small shell script that I wrote. For the name in the file /home/place/incoming/MYSQLIST_*.zip

  name = `echo $ file | awk -F "MYSQLIST_" {'print $ 2'} `#get Type name = 'Echo $ name | Unkip the extension $ {file} -d / home / place / incoming / name = gt; & Gt; Collect.txt directory = `resonance / home / location / incoming / $ {name}. Csv` $ directory & gt; & Gt; Collect.txt #cleanup rm $ {name} .csv rm phpvars.txt mv $ {file} $ {file} Dot done   

This script works as most of the time I have such files that come in this directory coming in the form of MYSQLIST _ #### Zip and MISQL _ ####### zip. As we would expect, this script should ignore files named MYSQL _ ## ###### Zip I have seen that the full name for the loop is to write the name MYSQL _ ######## to remove the zip and collect it.

Usually my collect.txt will be:

Type_21345

/home/place/incoming/type_12345.csv

However in some cases, this is what was found in collect.txt:

MYSQL_12345678

is /home/place/incoming/MYSQL_12345678.csv

It is possible that I am missing a catch in front of me for loop or I should have one in my loop to check that the name of the file is actually (MYSQLIST _ * .zip)?

I am not looking for any answers like "Give me the code", I would like to know whether anyone else has seen guidance in some similarities (misbehavior for the ends) or error checking.

If you want to provide quotation around your variables in the file names in the case of spaces or metachactors. Ie

  name = `resonance $ name .... must be   

  name = 'echo' $ Name "....`   

etc.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -