Архив рубрики: Linux

Волшебные замены в Vim, много файлов

Итак, Вам нужно сделать замену, описываемую регулярным выражением, в большом количестве файлов сразу.

Рассмотрим эту процедуру на примере добавления мета-тэга для перенаправления в группе html страниц. Даже если Вы ничего не понимаете в html, всё равно будет ясно, как делать замены в нескольких файлах одновременно.

Допустим, Вы решили вставить во все файлы tag <meta> такого вида:
1<meta http-equiv=»refresh» content=»seconds; URL-redirect-to»>

Существует много способов сделать перенаправление с адреса oldsite.ru/page_name на newsite.ru/page_name для каждой страницы. Наверняка большинство сделало бы такую операцию в perl или python. А я расскажу вам о самом волшебном способе: мы сделаем это в vim. Если Вы не знаете, что это такое, срочно покиньте эту страницу. Читать

Переименование файлов с помощью find, sed и xargs

Данное сообщение не претендует на оригинальность, это просто очередной пример того, как можно переименовать много файлов с помощью командной строки в Linux, используя find, sed, xargs и mv.

Общий вид

Идея такая: Читать

Установка Gentoo для лохов

Произносим правильно

Gentoo [↗dʒɛntu:, дже́нту] — вид пингвинов из рода антарктических, известен как быстрейший среди пингвинов в подводном плавании. Некоторые граждане привыкли к произношению «Генту», но это нестрашно: далее в руководстве будет использоваться только английский вариант. Читать

Выравнивание колонок в vim

Бывает, что сталкиваешься с такой вот табличкой:

Выравнивание в vim

Есть разные утилиты для выравнивания таблиц. Но обычно можно обойтись и без них — ведь наш файл и так открыт в vim, который умеет почти всё. Процесс выравнивания можно посмотреть на gif-анимации или mp4-видео. Читать

Align columns in vim

One may come across the table like this:

There are some utilities to align the columns in the table. But do you really need one, if you are already in vim? Have a look on the alignment process in gif animation or mp4 video.
The general idea is:

Paste enough spaces between the columns, so that the leftmost element from the second column will appear to the right relatively to rightmost element from the first column. In latex files like in the video/animation, & symbol serves as a delimiter between the columns, so I use :%s/&/          &/g to precede all the ampersands with bunch of spaces. How much exactly spaces you need depends on the cell length.

Select empty column in visual block mode via Ctrl + V. To move leftwards everything to the right of the selection, use <. Repeat the action as many times as you need with .. The video and the animation show this only for the first time, when second column is being aligned. It is not the shortest way, and it is shown only for better understanding of what’s going on.

Once you’ve selected an empty column, instead of <……. or so you may do 20<. This method is used to align the remainder of the table in the video/animation.

I started to learn vim about 5 years ago, when someone told me that vim knows how to work with columns. Since then this ability of vim is one of my favorites. I love vim!

Acestream on Ubuntu 16.04

Acestream (fork of the VLC player for video playback via torrents) was easy to install using apt-get on Ubuntu 14.04, but on Ubuntu 16.04 it is not in the repositories at the moment of writing (please let me know if it changes). One way is to install Acestream from source, but it could be difficult. The second way is was described here (Spanish, the link is dead already). I decided to gather all necessary files into an archive to make installation simpler. Читать