LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-17-2016, 12:13 AM   #1
Vthimmap
Member
 
Registered: Oct 2012
Posts: 36

Rep: Reputation: Disabled
Question 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
 
Old 11-17-2016, 12:17 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,773

Rep: Reputation: 7565Reputation: 7565Reputation: 7565Reputation: 7565Reputation: 7565Reputation: 7565Reputation: 7565Reputation: 7565Reputation: 7565Reputation: 7565Reputation: 7565
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?
 
Old 11-17-2016, 12:26 AM   #3
Vthimmap
Member
 
Registered: Oct 2012
Posts: 36

Original Poster
Rep: Reputation: Disabled
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
 
Old 11-17-2016, 02:41 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Arch
Posts: 10,021

Rep: Reputation: 3199Reputation: 3199Reputation: 3199Reputation: 3199Reputation: 3199Reputation: 3199Reputation: 3199Reputation: 3199Reputation: 3199Reputation: 3199Reputation: 3199
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.
 
Old 11-17-2016, 06:41 AM   #5
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
10.1. Manipulating Strings

Advanced Bash-Scripting Guide

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

Last edited by BW-userx; 11-17-2016 at 06:50 AM.
 
Old 11-17-2016, 02:53 PM   #6
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,894
Blog Entries: 13

Rep: Reputation: 4945Reputation: 4945Reputation: 4945Reputation: 4945Reputation: 4945Reputation: 4945Reputation: 4945Reputation: 4945Reputation: 4945Reputation: 4945Reputation: 4945
Member Response

Quote:
Originally Posted by Vthimmap View Post
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
 
Old 11-17-2016, 09:08 PM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,398

Rep: Reputation: 2779Reputation: 2779Reputation: 2779Reputation: 2779Reputation: 2779Reputation: 2779Reputation: 2779Reputation: 2779Reputation: 2779Reputation: 2779Reputation: 2779
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use Vi to match a string of text, add a new line, insert string... Slycraft Linux - Newbie 7 07-20-2012 10:24 AM
I want to insert a string into a form countrydj Programming 2 07-02-2012 01:37 PM
howto insert a string kscott121 Linux - Software 6 12-26-2006 03:50 PM
finding a dot in a string saavik Programming 2 10-02-2006 09:05 AM
insert string with sed greg108 Programming 7 02-18-2005 01:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration