![]() $ HEX=$(echo 0123456789abcdefghijklmnopqrstuvwxyz | tr -d -c '0-9a-f')īut, if you want to process the output of md5sum, that's not what you want because the filename could have characters that match '' and they would end up in your output:ĥ553ae9084e054b3fb742ac623e41dc5 temp.txt To do what you describe, I think you would be better using 'tr' to remove any characters that don't match '0-9a-f': Maybe you could explain what you are trying to do? Wouldn't it make more sense to have it accept just the sum? Having said all that, I'm not sure why you are expecting the argument to the -s option to be the raw output of md5sum. $ echo $MD5SUM | cut -delimiter=' ' -fields=1 An alternative to your grep, and perhaps slightly easier to read, is to use cut: Don't forget "#!/bin/bash" at the top of the script if you want to be sure bash is running the script.ģ. Using $() is usually easier to read than ``, e.g:Ģ. That allows you to pipe the content of that variable to another command:ġ. You could put the content of the variable onto stdout by using echo:Ģff24be63bf77643012865fc8ac5909b temp.txt If you put the output of md5sum into a variable, you don't put it on stdout just by naming the variable - bash thinks you are tring to run a command like "2ff24be63bf77643012865fc8ac5909b temp.txt" so it says command not found:Ģff24be63bf77643012865fc8ac5909b: command not found You are taking the output of md5sum (on stdout) and connecting it to the input (stdin) of grep, i.e. I'm not quite sure where you are going with this script but when you run something like this,
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |