LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   insert a dot in between a number string (https://www.linuxquestions.org/questions/linux-newbie-8/insert-a-dot-in-between-a-number-string-4175593689/)

Vthimmap 11-17-2016 12:13 AM

insert a dot in between a number string
 
Input
146870984704
1166734995456
3956629118976
75278372864

Output
146.870984704
1166.734995456
3956.629118976
75.278372864

Have to insert a dot after 9th position from last character.
OR Is there a way to convert bytes to GB format

pan64 11-17-2016 12:17 AM

where is this list from? commands like df or du have switches to display result in GB format.
from the other hand you can use sed/awk/perl/python/whatever to do that. Which one do you prefer?

Vthimmap 11-17-2016 12:26 AM

Need the disk space usage details on all the drives of a windows box from unix command line
The command which i have used displays in bytes, need it in GB


WMIC LOGICALDISK GET Name,Size,FreeSpace,FileSystem

Caption FileSystem FreeSpace Size

C: NTFS 146870984704 179980595200

D: NTFS 1166734995456 1319847849984

F: NTFS 3956629118976 22430185676800

G: NTFS 75278372864 900015845376

grail 11-17-2016 02:41 AM

Grab your favourite language and divide by either 1000 or 1024 until you get your required result. You can do it the way you wish as well with simple text manipulation.

BW-userx 11-17-2016 06:41 AM

10.1. Manipulating Strings

Advanced Bash-Scripting Guide

you forgot to say which language you need to do this in.

rtmistler 11-17-2016 02:53 PM

Member Response
 
Quote:

Originally Posted by Vthimmap (Post 5631490)
Need the disk space usage details on all the drives of a windows box from unix command line
The command which i have used displays in bytes, need it in GB


WMIC LOGICALDISK GET Name,Size,FreeSpace,FileSystem

Caption FileSystem FreeSpace Size

C: NTFS 146870984704 179980595200

D: NTFS 1166734995456 1319847849984

F: NTFS 3956629118976 22430185676800

G: NTFS 75278372864 900015845376

What command are you using? For instance if you're using df, there is a human readable format argument:
Code:

df -h

chrism01 11-17-2016 09:08 PM

It seems you have these values as strings (originally extracted from a MSWin system), so 3 options:

As above, if you can mount them from a Linux box, then 'df -h'.

If not, string manipulation using 'rev' eg
Code:

echo 12345|rev
and the links from BW-userx.

You're probably better to calc it as per grail.


All times are GMT -5. The time now is 07:37 PM.