[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: scripting problem



On Sat, Nov 26, 2005 at 10:08:58PM +0100, John Smith wrote:
>
> user@testbox:/home/user/tmp >cat t5.sh
> #!/bin/sh
> 
> export INPUT='$1$iW95z/HB$GFcYFxMKK6x8EUPglVkux.'
> 
> echo "1 ==="$INPUT"==="
> 
> export MD5PW=$(echo -n "$INPUT" |  hexdump -v -e '" " 1/1 "%02d"')
> 
> echo "2 ==="${MD5PW}"==="
> 
> echo -n "3 ===";echo -n ${MD5PW} | tr ' ' '\n' | while read char ; do echo $char | awk '{printf("%c",$1)}' ; done ; echo "==="
> user@testbox:/home/user/tmp >./t5.sh
> 1 ===$1$iW95z/HB$GFcYFxMKK6x8EUPglVkux.===
> 2 === 36 49 36 105 87 57 53 122 47 72 66 36 71 70 99 89 70 120 77 75 75 54 120 56 69 85 80 103 108 86 107 117 120 46===
> 3 ===$1$iW95z/HB$GFcYFxMKK6x8EUPglVkux===

I don't know what the purpose of this code is, but I recommend learning
perl:

perl -lpe 'print; s/(\S)/sprintf "%i ", ord $1/eg; print; s/(\d+) */chr $1/eg'

This preserves the trailing ".".



Reply to: