Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find and replace text in a 47GB large file [closed]

I have to do some find and replace tasks on a rather big file , about 47 GB in size .

Does anybody know how to do this ? I tried using services like TextCrawler , EditpadLite and more but nothing supports this large a file .

I'm assuming this can be done via the commandline .

Do you have an idea how this can be accomplished ?

like image 307
Shrayas Avatar asked Aug 05 '11 05:08

Shrayas


People also ask

Does sed work on large files?

This week, I've been using sed quite a lot. sed is short for stream editor, and is designed to work with large amounts of streaming text.

How do I find and replace text in multiple files?

Remove all the files you don't want to edit by selecting them and pressing DEL, then right-click the remaining files and choose Open all. Now go to Search > Replace or press CTRL+H, which will launch the Replace menu. Here you'll find an option to Replace All in All Opened Documents.

How do I replace all instances of a text file in Word?

Open the text file in Notepad. Click Edit on the menu bar, then select Replace in the Edit menu. Once in the Search and Replace window, enter the text you want to find and the text you want to use as a replacement. See our using search and replace and advanced options section for further information and help.

How do I find and replace text in multiple files in Linux?

Find and replace text within a file using sed command Use Stream EDitor (sed) as follows: sed -i 's/old-text/new-text/g' input.txt. The s is the substitute command of sed for find and replace. It tells sed to find all occurrences of 'old-text' and replace with 'new-text' in a file named input.txt.


2 Answers

Sed (stream editor for filtering and transforming text) is your friend.

sed -i 's/old text/new text/g' file 

Sed performs text transformations in a single pass.

like image 58
Ryan Avatar answered Sep 21 '22 08:09

Ryan


I use FART - Find And Replace Text by Lionello Lunesu.

It works very well on Windows Seven x64.

You can find and replace the text using this command:

fart -c big_filename.txt "find_this_text" "replace_to_this" 

github

like image 34
JorgeKlemm Avatar answered Sep 20 '22 08:09

JorgeKlemm