[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
can print base 64 numbers in base 10 but not visa versa
From: |
Dan Jacobson |
Subject: |
can print base 64 numbers in base 10 but not visa versa |
Date: |
11 Feb 2002 17:07:21 +0800 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 |
It seems in bash all I can do is print base 64 things out in base 10,
but not base 10 things out in base 64?
all I can do is make things get longer, not compress them, at least if
my goal is beyond base 16, no?
$ echo $((44#434))
7880
anyways. is there some other shell utility that will do what I want?
I see bc has obase...
echo obase=64\; `date +%s`|bc
60 25 56 24 30
wait [forget printf(1)'s %c]...
$ echo obase=26\; `date +%s`|bc|awk '{for (i=1;i<=NF;i++)printf
"%c",$i+97;print ""}'
dhhrezz
$ echo obase=26\; `date +%s`|bc|awk '{for (i=1;i<=NF;i++)printf
"%c",$i+97;print ""}'
dhhrfaa
OK, I've got it contained within a safe stretch of ascii for a
filename... ok, that was a fun exercise. enough excitement for
now. conclusion: why doesn't bash catch up to kornshell?
|doesn't use *all* printing characters, but in ksh93, you can do:
|
|typeset -i64 date=$(date +%s)
|print ${date#64#}
>>>>> "Dan" == Dan Jacobson <jidanni@deadspam.com> writes:
Dan> What's the shortest way I can express a time string using all printing
Dan> characters?
Dan> E.g.
Dan> $ date +%s
Dan> 1013147079 #is my time string, it's nice, but too long
Dan> $ printf %x\\n $(date +%s)
Dan> 3c6365ee #is nicer, but why limit myself to just the hex range? what
command
Dan> could pull more letters into play, but still leave it sortable by, say,
Dan> ls(1) if these stings were used in filenames.
[posted separately to bash & c.u.shell groups]
--
http://www.geocities.com/jidanni/ Taiwan(04)25854780
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- can print base 64 numbers in base 10 but not visa versa,
Dan Jacobson <=