How I can add the file extension inside of the shell injection without having to use ruby to add the extension? I'd prefer to keep the solution inside of the backticks.
Code:
def self.md5_sum(uri)
`md5 -s $(basename #{uri}) | cut -d"=" -f2 | \
tr -d "\n "` + uri[-4..-1]
end
=> "8de6a806194b000c51eee39e35b470ec.jpg"
What I came up with:
(Note the file extension could end in ".png")
Code:
`md5 -s $(basename #{uri}) | cut -d"=" -f2 | \
awk '{ print $1, ".jpg" }' | tr -d "\n "`