-
Notifications
You must be signed in to change notification settings - Fork 0
/
psindoublearray2.sh
34 lines (32 loc) · 1.06 KB
/
psindoublearray2.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
# ******************************************************************************************
# *
# * File: psindoublearray2.sh
# *
# * Function: Puts in two arrays data for all the processes in the system
# *
# * Author: Luca Marzo
# *
# * Course: Sistemi Operativi I - Facoltà di Ingegneria - Università del Salento
# *
# * Copyright: CreativeCommons 2012 - Attribution-Noncommercial-Share Alike 2.5 Generic
# *
# * Notes: a second version of psindoublearray.sh, where the PID
# * from the first array is used as an index
# * for the second array (which therefor will be sparse)
# *
# * Change History:
# * Thu Apr 19 16:12:41 CEST 2012 Prima stesura
# *
# ******************************************************************************************
#
primoarray=($(ps -e -opid=))
for ((i=0; i < ${#primoarray[*]}; i++ ))
do
secondoarray[${primoarray[i]}]=$(ps -p ${primoarray[i]} -oppid=)
done
#Stampa a video gli array creati
for (( i=0; i < ${#primoarray[*]}; i++ ))
do
echo ${primoarray[i]}' <---> '${secondoarray[${primoarray[i]}]}
done