finde ich habe diesen Code:Speicher Wert in bash Array gibt [array] nicht
#!/bin/bash
PIDS=$(ls -la /proc | awk '{print $9}' | grep "^[0-9]*$")
PIDLIST=$(echo $PIDS | tr "" "\n")
counter=0
for PID in $PIDLIST; do
KERNEL[$counter]=$(cat "/proc/$PID/stat" | awk '{print $14 }')
counter=$((counter + 1))
done
Ich versuche, den Inhalt von cat "/proc/$PID/stat" | awk '{print $14 }'
Befehl in einem benannten KERNEL Array zu speichern, um eine Position durch einen Zähler gegeben.
Ich habe diesen Fehler:
mitop.sh: 8: mitop.sh: KERNEL[0]=26: not found
Was mache ich falsch?
[email protected]:~$ bash --version
GNU bash, versión 4.2.24(1)-release (i686-pc-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
Licencia GPLv3+: GPL de GNU versión 3 o posterior <http://gnu.org/licenses/gpl.html>
Was passiert, wenn Sie -a kernel 'vor Ihrer 'for' Schleife hinzufügen' erklären? – eddiem
Verwendung von declare -> mitop.sh: 6: mitop.sh: declare: nicht gefunden und ich benutze Version 4.X – colymore
Führen Sie das Skript mit './Mitop.sh' oder auf andere Weise, zum Beispiel 'sh./mitop.sh'? Es ist wichtig. – janos