8

I am running Mac OS X 10.8.4 (Mountain Lion) and I am trying to open and scroll through a 42 GB .XML file.

I plan on using an XML parser to parse through it and delete parts, but first I need to know how the document is structured so I can know what parts to save.

How can I open this text / XML file and scroll through it so I can get a glimpse of its structure?

I tried my default text-editor, text-mate, and that couldn't open it. I tried gEdit and that shows the first 10 or so lines, but then quits after trying to load the rest.

I would greatly appreciate any and all suggestions!

2
  • I'm wondering if any of these suggestions worked for you - I gave up on vi after waiting a minute to load a 63 MB file, and less crashes my terminal after navigating a few pages down.
    – Ed Norris
    Jan 9, 2017 at 18:56

6 Answers 6

10

The easiest way is to use a terminal pager. Open a terminal and run

less file.txt

or

more file.txt
3
  • less has more chance of dealing with these kind of files.
    – bayindirh
    Jun 25, 2013 at 13:47
  • Thank you! Any suggestions on how I can edit it? Or should I let the script do that? Jun 25, 2013 at 13:48
  • @DjangoJohnson probably best to let the script do it or to use something like sed.
    – terdon
    Jun 25, 2013 at 13:59
11

Well, hexfiend is what I use, and love to use...

enter image description here

If it is a text file, you just go to Views and uncheck Hexadecimal option, it will show only text.

So, for example I scrolled to line: 37802466 superfast, no glitches...

2
  • 3
    well we need to modify this to show view with new lines. Then we found our notepad++ on mac.
    – Olgun Kaya
    Jun 19, 2017 at 5:23
  • Perfect solution and great editor Nov 4, 2021 at 15:33
1

vi will not read all file at once and will cache it. Give it a try. It can also syntax-hihglight it, so it's a plus over less.

3
  • I tried to edit your good reply so as to place "`" around vi and less. But so minor a correction was rejected by e-boss. I just tried vi on 1 Gbyte file. It's quite fast.
    – dan
    Jun 25, 2013 at 14:07
  • 1
    I have more power over my answers. :)
    – bayindirh
    Jun 25, 2013 at 14:16
  • 1
    "It's a plus over less" ;).
    – dan
    Jun 25, 2013 at 14:31
1

The best tool for opening large text files and searching for content I found was glogg

glogg is a multi-platform GUI application that helps browse and search through long and complex log files. It is designed with programmers and system administrators in mind and can be seen as a graphical, interactive combination of grep and less.

Unfortunately the oficial website is down. But you can download the latest release on archive.org

Although the program has not received updates for a few years. It works normally on MacOs 12 Monterey

1
  • Please read How do I recommend software for some tips as to how you should go about recommending software. You should provide at least a link, some additional information about the software itself, and how it can be used to solve the problem in the question.
    – DavidPostill
    Sep 12, 2018 at 15:25
1

I followed ricardo's answer and found https://github.com/variar/klogg

This is made for browsing and searching huge (log) files and has excellent search options

Apart from features of glogg it has dark mode that most of us need

2
  • How is this answer better than the one you are referring to? Jul 14, 2022 at 5:38
  • @DarkDiamond The answer I was referring to is about glogg, which does not support dark mode and is not maintained. The newer one I found klogg supports Dark mode while it can handle huge files as well, so I thought this deserves a separate answer to make is visible to anyone like me who is looking for such a solution. Jul 14, 2022 at 10:45
0

As @terdon already said: Terminal pagers will work regardless how big the file is.
(42 GB... Just curious how you managed to get a file that big...)

TextWrangler might be able to deal with it.
I just verified that TextWrangler has a maximum limit of about 380 MB per file.

If you have a PC handy (or Wine) you can try the trail version of UltraEdit.
This can 100% certain deal with such files.

7
  • It is a crawl of content from the internet. Part of the internet. I don't have a PC handy. What if I need to edit it on a mac, what do I do then? Jun 25, 2013 at 13:49
  • UltraEdit is known to work on a Mac using Wine. I routinely use it to edit files larger than the RAM of the computer. TextWrangler which is a native Mac-app might be able to do it too, but I don't know that for sure. I don't have a Mac nearby to verify that.
    – Tonny
    Jun 25, 2013 at 14:40
  • Try vi. Seriously.
    – bayindirh
    Jun 25, 2013 at 14:41
  • 2
    @SilentStorm That's what I would do :-) , but if someone needs to ask for a tool, vi(m) is probably not the right tool for him/her. Let's be honest... VI has a learning curve. Something we Unix guys sometimes tend to forget. For someone who grow up with a point and click interface VI is scary like hell.
    – Tonny
    Jun 25, 2013 at 14:44
  • 1
    @Tonny VIM is scary. I'm trying to avoid it. But I will use it if I must. Jun 25, 2013 at 20:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .