AWK - Необходимо отобразить общее значение поля и номер поля

Si el dispositivo no es una unidad de CDROM, ejectrecurre a un comando SCSI genérico "START STOP", con la opción "expulsar" configurada.

Es posible enviar al revés, "START STOP" con la opción "start", usando sg_start -s. sg _start está disponible como parte del paquete sg3 _utils en la mayoría de las distribuciones.

Aparentemente, sg_start -sfue suficiente para reiniciar la unidad en este caso. sg_start --loadno era necesario. (Esto tiene sentido para mí, porque no veo esto como una expulsión que ha tenido lugar ).

Otros usuarios han afirmado que esto no funciona. Los controladores de unidades USB, especialmente para unidades flash pequeñas, pueden ser un poco extraños, por lo que no me sorprendería si algunas unidades rechazaran este comando.

https://unix.stackexchange.com/a/394961/29483

The USB controller in a flash ROM stick usually reacts by powering down the device and preventing any further interaction. That means it disappears completely from the USB subsystem, and must be re-enumerated to be able to accessed again.

The same command when send e.g. to a CD/DVD drive will eject the disk, and the also existing "load" option of the "START STOP" command will load it again. But this interpretation only applies to devices with removable media.

0
23.05.2019, 12:55
2 ответа

Вы можете использовать:

awk -F"," '{for (i=5;i<=NF;i++){a[i]=a[i]+$i}} END { for (i in a){ print "Field" i "=" a[i]}}' file

В вашем случае будет напечатано

Field5=42
Field6=107
Field7=32
Field8=101
Field9=15
Field10=1
Field11=0
Field12=0
Field13=0
0
28.04.2021, 23:33

Пробовал с awk ниже, и это сработало как шарм; команды:

j=`awk -F ","  '{print NF}' filename| sort -nr| sed -n '1p'`
for ((i=5;i<=$j;i++)); do awk -v i="$i" -F "," 'BEGIN{sum=0}{sum=sum+$i}END {print "Field"i"=" sum}' filename; done| perl -pne "s/\n/, /g"

выход:

Field5=42, Field6=107, Field7=32, Field8=101, Field9=15, Field10=1, Field11=0, Field12=0, Field13=0
0
28.04.2021, 23:33

Теги

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