Bash script has errors
First, i am a newbie with bashscripts.
I wrote a bash script that is suppose to check if two files have equal checksome; but it has errors. here are the errors : Code:
./chk.sh: line 2: [pw: command not found Code:
#/bin/bash |
You could try this:
Code:
#/bin/bash I'd suggest reading the Advanced Bash Scripting Guide, it's got a range of techniques and good explanations. |
you can just use cmp
Code:
$ cmp file1 file2 |
Quote:
|
This works, any suggestions on how to improve it? code looks messy.
Code:
#!/bin/bash |
Quote:
Code:
$ md5sum file1 file2 | uniq -d -w32 |wc -l |
Your problem is that you don't have spaces after [ and before ]; that means the shell concatenates what's next to it, preventing it from finding an appropriate command.
Kevin Barry PS Why do you end lines with :? |
Quote:
|
Quote:
Quote:
|
Quote:
|
Quote:
Kevin Barry |
Quote:
Code:
while : |
Quote:
Code:
#!/bin/bash |
Ending the script with a ':' is equivalent to having the last line of the script be:
exit 0 Having it at the end of each line will give each line of code an exit status of '0' which is probably not a good thing -I mean if you do error checking after running a line of code, having ':' at the end would destroy whatever exit code the line of code ahd generated. |
Quote:
Code:
./chk.sh chk.sh hello |
All times are GMT -5. The time now is 06:37 PM. |