LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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, 01:13 AM   #1
Vthimmap
Member
 
Registered: Oct 2012
Posts: 34

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, 01:17 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 8,508

Rep: Reputation: 2434Reputation: 2434Reputation: 2434Reputation: 2434Reputation: 2434Reputation: 2434Reputation: 2434Reputation: 2434Reputation: 2434Reputation: 2434Reputation: 2434
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, 01:26 AM   #3
Vthimmap
Member
 
Registered: Oct 2012
Posts: 34

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, 03:41 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,424

Rep: Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823Reputation: 2823
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, 07:41 AM   #5
BW-userx
Senior Member
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Void Linux / Slackware 14.2
Posts: 3,109

Rep: Reputation: 543Reputation: 543Reputation: 543Reputation: 543Reputation: 543Reputation: 543
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 07:50 AM.
 
Old 11-17-2016, 03:53 PM   #6
rtmistler
Moderator
 
Registered: Mar 2011
Location: Sutton, MA. USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu
Posts: 4,479
Blog Entries: 10

Rep: Reputation: 1641Reputation: 1641Reputation: 1641Reputation: 1641Reputation: 1641Reputation: 1641Reputation: 1641Reputation: 1641Reputation: 1641Reputation: 1641Reputation: 1641
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, 10:08 PM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,260

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
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 11:24 AM
I want to insert a string into a form countrydj Programming 2 07-02-2012 02:37 PM
howto insert a string kscott121 Linux - Software 6 12-26-2006 04:50 PM
finding a dot in a string saavik Programming 2 10-02-2006 10:05 AM
insert string with sed greg108 Programming 7 02-18-2005 02:11 PM


All times are GMT -5. The time now is 07:00 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration