Переключение символов в строке с помощью sed

Es posible que la placa base admita 4 DIMM, pero el OEM optó por dejar disponibles solo dos ranuras y omitió las otras dos para ahorrar espacio o algo así. Siguiendo los documentos de Lenovo para agregar RAM al L420 , solo dos están realmente disponibles.

Esta publicación de SU es informativa:

It might be showing that the chipset supports more slots, even if the motherboard is not wired up to have those slots. It is more common these days for the chipset to know the other sots are not present (rather than just empty) but this is not always the case.

...

With laptops you often find that there are two slots, one on either side of the motherboard. In these cases one is usually easily accessible via the under-side of the case (under a cover held in place by one or two screws) and the other is on the other side of that and difficult to get to (you end up having to take the laptop completely apart if you want to get to it, and even then you might fins it isn't a real "slot" but some memory chips soldered direct to the board).

En mi propio System76 Bonobo de 2012, que tiene 4 ranuras, dos están en el extremo -de fácil acceso de la placa base (cerca del disco duro y las ranuras de la batería ), y las otras dos requieren que yo prácticamente desmontamos el portátil para acceder a él. Así que supongo que Lenovo se saltó menos -puertos accesibles, reduciendo el costo y la complejidad.

1
11.02.2019, 05:47
2 ответа

Сгруппируйте части выражения со скобками, а затем вызовите эти группы в другом порядке с помощью \n, где n— индекс группы. Например

$ echo 12345678 | sed -E 's/(.)(.)(.)(.)/\1\4\3\2/'
14325678
2
28.04.2021, 23:37

Вы можете сделать это несколькими способами:

 echo 12345678 |
 sed -e '
    s/./&\n/4
    s/./\n&/2
    s/\n\(.\)\(.*\)\(.\)\n/\3\2\1/
 '
 14325678

 perl -lne 'print+(unpack "AAAAA*")[0,3,2,1,4]' 

 perl -F -lane '@F[1,3] = @F[3,1];print @F'

 awk -F "" '{t=$2;$2=$4;$4=t}1' OFS=

С помощью awk разделите пустую строку, чтобы каждый символ стал полем, которые затем перемешиваются и с помощью Ofs var переносятся на стандартный вывод.

В Perl мы распаковываем строку, используя шаблон ascii, затем меняем порядок и, наконец, выводим на стандартный вывод. Значение Ofs по умолчанию равно нулю.

С помощью sed сначала мы помечаем символы, которые необходимо перевернуть. Затем на последнем этапе мы обмениваем их с помощью маркеров. Этот метод масштабируется с любыми двумя позициями символов, которые вы можете поменять местами.

ХТН.

1
28.04.2021, 23:37

Теги

Похожие вопросы