[opensuse] bash question - killing leading zeros?
All, I have a script that gets to a line equivalent to: echo $((0024748032 * 512)) It dies because it is interpreting that as octal (I assume). How can I trim off the leading zeros? Thanks Greg -- Greg Freemyer -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
[26.08.2013 19:14] [Greg Freemyer]:
All,
I have a script that gets to a line equivalent to:
echo $((0024748032 * 512))
It dies because it is interpreting that as octal (I assume).
How can I trim off the leading zeros?
Hi Greg, I tried ${var##0}, but this did not work. It only eliminates one 0. So I tried to convince the bash that 0024748032 is a decimal number, and it worked: MYVAR=0024748032 MYVAL=10#$MYVAR echo $((MYVAL * 512)) If the numbers are hardcoded, you can write echo $((10#0024748032 * 512)) and everything is fine, but I suspect that you use variables ;-) Now I hope that you use bash... Werner -- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On Mon, Aug 26, 2013 at 2:22 PM, Werner Flamme <werner.flamme@email.de> wrote:
[26.08.2013 19:14] [Greg Freemyer]:
All,
I have a script that gets to a line equivalent to:
echo $((0024748032 * 512))
It dies because it is interpreting that as octal (I assume).
How can I trim off the leading zeros?
Hi Greg,
I tried ${var##0}, but this did not work. It only eliminates one 0. So I tried to convince the bash that 0024748032 is a decimal number, and it worked:
MYVAR=0024748032 MYVAL=10#$MYVAR echo $((MYVAL * 512))
If the numbers are hardcoded, you can write echo $((10#0024748032 * 512)) and everything is fine, but I suspect that you use variables ;-)
Now I hope that you use bash...
Werner
Fantastic, thanks (and yes variables and bash both) fyi: 0024748032 is the starting sector of a partition. $((10#0024748032 * 512)) is the starting byte of a partition. So this command now dumps a list of NTFS shadow volumes in a partition: vshadowinfo -o $((10#$offset * 512)) /dev/sdb - offset comes from the output of mmls /dev/sdb and some bash manipulation - mmls comes from sleuthkit (in the main repo) vshadowinfo is new to factory. (zypper in libvshadow-tools) Then vshadowmount can be used to create virtual devices corresponding to the VSCs (volume shadow copies). Those in turn can be mounted loopback to access the files inside the VSCs. I suspect openSUSE 13.1 will be the first distro with that ability included! (I may be the only one who cares, but I'm pretty excited for that to be true.) Greg -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 8/26/2013 3:27 PM, Greg Freemyer wrote:
So this command now dumps a list of NTFS shadow volumes in a partition:
vshadowinfo -o $((10#$offset * 512)) /dev/sdb
- offset comes from the output of mmls /dev/sdb and some bash manipulation
- mmls comes from sleuthkit (in the main repo)
vshadowinfo is new to factory. (zypper in libvshadow-tools)
Then vshadowmount can be used to create virtual devices corresponding to the VSCs (volume shadow copies). Those in turn can be mounted loopback to access the files inside the VSCs.
That is outstanding! -- bkw -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
participants (3)
-
Brian K. White
-
Greg Freemyer
-
Werner Flamme