Help Shellscript
I am trying to write shellscript which could read a path, go through the content of the path, determine the type for each file under the directory path and finally write the result to a registry file. My code doesn't work and I don't know where the mistake is... help !:(
Code:
|
Sorry I paste the wrong code (though anyway this one is also wrong )
Code:
|
You're making assignments, not comparisons.
Cheers, Tink |
There is a simpler way to do what you are trying to do. Take a look at the code below:
Code:
#!/bin/bash |
Thanks looseCannon for the select statement tips! I made it complicated because I wanted to exercise with functions, but I get these kind of mistake:
Enter path: project1: createRegistry: command not found Code:
|
I did not check if this script can work, but it seems you are asking the shell to execute a function (basically a command) that will be created later....
Hope this helps Ciao PS in the function definition you wrote createRegitry (there is an "s" missing anyway) |
Thanks urka58! and all of you. Yeap! didn't see the "s" missing, time to have a break now! I though I could create a function wherever in the code like in for instance Java, well now I know, thanks :)
Code:
#!/bin/bash |
Another thing I'll throw in...
if [[ $choice = c || $choice = C ]] I've never been able to get an OR to work in ksh. You're using bash, so it might work. Generally I use the 'tr' command to translate things to either uppercase or lower case. Something like this: Code:
UPPERCASE=`echo $choice|tr [a-z] [A-Z]` Last thing: the general rule with functions is to put them at the top of your script. This is because the scripts are executed a line at a time and a function at the bottom won't be seen until the very end of the script. When you put it at the top it is loaded into memory and can be used at any point during the script. |
All times are GMT -5. The time now is 07:28 AM. |