2

I am connected to a server where I don't have sudo privileges to install packages such as Libreoffice. I only want to view an excel file might be .xlsx or .xls on linux terminal with a command line, is there an easy way to do that?

kutlus
  • 345
  • 2
  • 5
  • 18
  • 1
    scp it to a Windows machine? – Jeff Schaller Jan 16 '19 at 20:29
  • 1
    Well, *easy* differs from one person to another. excel files are actually compressed xml files (along with some other data). So, when you decompress an excel file, you will see the file content in xml format. Have fun! – joker Jan 16 '19 at 20:31
  • I tried that but there are many folders with excell files in them and i need to check if which one is complete, I want to able to do it with a command line so it will be faster,thnaks – kutlus Jan 16 '19 at 20:33
  • You need to check the directories extracted and view all candidate xml files until you find your target. – joker Jan 16 '19 at 20:35

1 Answers1

3

You can't do that. XLS and XLSX are binary format data files and you need a tool that can unpack them in order to be able to view the contents. (To be precise, XLSX is compressed XML, but its unsupported readability is exceedingly low.)

roaima
  • 107,089
  • 14
  • 139
  • 261
  • That's a wrong answer. They are not binary files. They are compressed files. You can decompress those and find xml files inside. – joker Jan 16 '19 at 20:32
  • You edited the answer. However, you should remove *binary format*. That's not correct. – joker Jan 16 '19 at 20:34
  • Thanks Roaima. Also what package would be the best to install, libreoffice or something different? – kutlus Jan 16 '19 at 20:40
  • @joker, IMO _binary format_ is correct. The format may start with a ZIP container but it's not text. Microsoft's definition (added to my answer) also considers XLS to be a binary format file. – roaima Jan 16 '19 at 20:41
  • @kutlus I can't advise you on what's _best_ because I don't know your situation. For example, if you're running on a headless system with no GUI installed then LibreOffice or OpenOffice would not be a good suggestion. If you wanted to look at the file structure then something like `xmlstarlet` might be good. But then again it might be way too low-level. I really can't advise you. – roaima Jan 16 '19 at 20:43
  • @roaima, do you consider `file.zip` a binary file? or `file.tar.gz` is a binary file? Does a compressed file with a different extension make any difference? That's what I am trying to say. So, using *binary format* would throw readers off. – joker Jan 16 '19 at 20:54
  • You can use unzip in Unix to uncompress them. However the readability is indeed pretty low – Rui F Ribeiro Jan 16 '19 at 21:14
  • @RuiFRibeiro just re-checked. XLS is binary format data files in a ZIP container. (`file` returns `data` when querying the content.) – roaima Jan 16 '19 at 22:39
  • 1
    Yeah, been unzipping them in the last few years. Now if you ask me why, can't remember. Good news, it is not alzheimer yet ;) – Rui F Ribeiro Jan 16 '19 at 22:43