LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 01-07-2015, 03:54 AM   #1
saeedsssss
Member
 
Registered: Apr 2012
Posts: 43

Rep: Reputation: Disabled
convert df -h output to exel


Hi
I want convert df -h output to exel
how we can doing this?
#df -h

/dev/mapper/vg01-lvroot
200G 608M 18G 4% /
/dev/mapper/vg01-lvtmp
250G 1.7G 22G 8% /tmp
/dev/mapper/vg01-lvopt
200G 1.1G 18G 6% /opt
/dev/mapper/vg01-lvhome
200G 173M 19G 1% /home
/dev/mapper/vg01-lvvar
200G 400M 18G 3% /var
/dev/mapper/vg01-lvusr
200G 5.1G 14G 28% /usr
/dev/mapper/vg01-lvoracle
30G 1.6G 27G 6% /oracle
/dev/mapper/vg01-lv_rocra_home
30G 14G 15G 49% /rocra_home
/dev/cciss/c0d0p1 99M 21M 74M 22% /boot
tmpfs 32G 0 32G 0% /dev/shm
ff03:/dd
19T 3.1T 8.0T 28% /dd
ff03:/pp
19T 5.3T 5.7T 49% /pp
 
Old 01-07-2015, 04:07 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 8,647

Rep: Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501
I assume you are speaking about excel, and not only that but csv format. You need to use sed or tr to replace space chars to commas.
 
Old 01-07-2015, 07:03 AM   #3
saeedsssss
Member
 
Registered: Apr 2012
Posts: 43

Original Poster
Rep: Reputation: Disabled
YES
I speaking about .xlsx

how we must using from sed or tr ?
please help me.
 
Old 01-07-2015, 07:07 AM   #4
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 8,647

Rep: Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501
http://www.linfo.org/tr.html
 
Old 01-07-2015, 07:16 AM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 15,393

Rep: Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652
Excel can import text files using many different separators other then a comma.
What happens if you save the output to a file and open it up in Excel?
 
Old 01-07-2015, 07:18 AM   #6
saeedsssss
Member
 
Registered: Apr 2012
Posts: 43

Original Poster
Rep: Reputation: Disabled
really i want similar below for all lines of df -h output.

/dev/mapper/vg01-lvroot ----> /dev/mapper/vg01-lvroot 200G 608M 18G 4% /
200G 608M 18G 4% / ---->

if you can help me with any way or with any command?
 
Old 01-07-2015, 07:27 AM   #7
saeedsssss
Member
 
Registered: Apr 2012
Posts: 43

Original Poster
Rep: Reputation: Disabled
please see this picture
Click image for larger version

Name:	wewant.png
Views:	43
Size:	172.3 KB
ID:	17300
 
Old 01-07-2015, 07:28 AM   #8
michaelk
Moderator
 
Registered: Aug 2002
Posts: 15,393

Rep: Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652
Use
df -Ph
 
Old 01-07-2015, 07:35 AM   #9
saeedsssss
Member
 
Registered: Apr 2012
Posts: 43

Original Poster
Rep: Reputation: Disabled
self of way with command df -Ph sloved.

but i want a part on a cell

foe example
/dev/mapper/vg01-lvroot -> a cell
200G -> a cell
608M -> a cell
18G -> a cell
4% -> a cell
 
Old 01-07-2015, 07:41 AM   #10
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 8,647

Rep: Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501
you need to open text file and specify delimiter in excel or replace spaces to comma (using tr)
 
Old 01-07-2015, 07:44 AM   #11
michaelk
Moderator
 
Registered: Aug 2002
Posts: 15,393

Rep: Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652Reputation: 1652
Try using the import wizard and select space as the separator. Its been awhile since I've needed to import a similar file.
 
Old 01-07-2015, 07:47 AM   #12
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 8,647

Rep: Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501Reputation: 2501
That depends on the version of excel, I have just tried MS Excel 2010 and there was no import but open ...
 
Old 01-07-2015, 09:03 AM   #13
saeedsssss
Member
 
Registered: Apr 2012
Posts: 43

Original Poster
Rep: Reputation: Disabled
Tank-you
every thing correct
goodbye.
 
Old 01-07-2015, 09:16 AM   #14
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,062

Rep: Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856
the op is off premise. unless you are a m$ employee and have legal access to their source code would one be able to transpose ascii text into proprietary binary xlsx format (you would have better luck with open/libre-office (xml) odf format but would probably be overkill).

as suggested use linux programs (like sed, awk, tr, cut, paste, ...)to format into something like *.csv.

with ms-excel 2010 there is a quirk (bug ?) where if you name a txt file with a xls suffix (not xlsx) it will open the file without the text import wizard. if you close the worksheet (but dont close excel) and then open the file ribbon and select recent and select the latest file, it will reopen with the text import wizard).
 
Old 01-07-2015, 02:09 PM   #15
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,661

Rep: Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256Reputation: 1256
It looks like you did a cut and paste from a terminal window into the spreadsheet (that would explain the odd line wrap).

you might try "df -h >file", then import the file.

Normally, df only outputs one line per filesystem - thus long filesystem names (or mounted on names, or both) could cause the output to be wrapped.

Otherwise, you will be stuck with using awk to combine lines, break up the lines into fields, and output with commas.
 
  


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 convert MIBs to snmpwalk output? ronbarak Linux - Software 3 05-26-2013 02:41 PM
[SOLVED] Convert du output to MB/GB...? Xeratul Linux - Newbie 9 09-05-2011 07:21 PM
load exel spreadsheet into ooo calc? Matthew O'Brien Linux - Newbie 1 04-25-2008 04:21 PM
openoffice crashes when saving certain exel files oily_rags Linux - Software 0 10-16-2004 09:04 PM
exel file chrisp Linux - Newbie 2 11-26-2001 08:23 AM


All times are GMT -5. The time now is 12:28 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