Автор Тема: Как в никсах редактировать огромные файлы???  (Прочитано 5338 раз)

crazy_man

  • Пользователь
  • **
  • Сообщений: 68
Еслть файлик 18  гигов, каким боком можно его отредактировать ? Нужно изменить одну строчку

nlive

  • Гость
Как в никсах редактировать огромные файлы???
« Ответ #1 : 19 Декабрь 2013, 01:48:29 »
Можно воспользоватся регулярными выражениями , благо линукс это тебе не винда
Код
sed \'s#\\(,\\)\\([^.,]\\+\\.\\(jpg\\|png\\|gif\\)\\)#\\1+\\2#g\' infile

Explanation:
s#...#...#g             # Substitute command. \'#\' is separator and \'g\' is to apply it many times for
                        # each line.
\\(,\\)                   # Match a comma, and save it as \'\\1\'
[^.,]\\+\\.               # Match any characters until a \'.\' or \',\' found.
\\(jpg\\|png\\|gif\\)       # Match extension.
\\1+\\2                   # Replace with: Comma, plus sign and the image name.

Если не регулярка, то
Код
Sed has several commands, but most people only learn the substitute command: s. The substitute command changes all occurrences of the regular expression into a new value. A simple example is changing \"day\" in the \"old\" file to \"night\" in the \"new\" file: 

sed s/day/night/ new
Ну а если редактироваать именно хочешь, то такое файло надо сначало разбить на мого мелких. Отредактироавать и  потом склеить назад
Нашел на одном из форумов
Код
I had a 12GB file to edit today. The vim LargeFile plugin did not work for me. It still used up all my memory and then printed an error message :-(. I could not use hexedit for either, as it cannot insert anything, just overwrite. Here is an alternative approach:

You split the file, edit the parts and then recombine it. You still need twice the disk space though.


Grep for something surrounding the line you would like to edit:
grep -n \'something\' HUGEFILE | head -n 1


Extract that range of the file:
sed -n -e \'4,5p\' -e \'5q\' HUGEFILE > SMALLPART
The -n option is required to suppress the default behaviour of sed to print everything
4,5p prints lines 4 and 5
5q aborts sed after processing line 5


Edit SMALLPART using your favourite editor.


Combine the file:
(head -n 3 HUGEFILE; cat SMALLPART; sed -e \'1,5d\' HUGEFILE) > HUGEFILE.new

HUGEFILE.new will now be your edited file, you can delete the original HUGEFILE.

nlive

  • Гость
Как в никсах редактировать огромные файлы???
« Ответ #2 : 19 Декабрь 2013, 01:49:46 »
Если gui - то есть классная тулза (специально для просмотра логов)
glogg - http://glogg.bonnefon.org/description.html