Mides pantalla¶
Es disposa de la comanda xwininfo que mostra informació tècnica sobre una finestra del escriptori o sobre el propi escriptori.
Per exemple,
usuari@computador:mp $ xwininfo
xwininfo: Please select the window about which you
would like information by clicking the
mouse in that window.
xwininfo: Window id: 0xe00028 "Escriptori"
Absolute upper-left X: 0
Absolute upper-left Y: 0
Relative upper-left X: 0
Relative upper-left Y: 0
Width: 1280
Height: 1024
Depth: 24
Visual: 0xdd
Visual Class: TrueColor
Border width: 0
Class: InputOutput
Colormap: 0xe00027 (not installed)
Bit Gravity State: NorthWestGravity
Window Gravity State: NorthWestGravity
Backing Store State: NotUseful
Save Under State: no
Map State: IsViewable
Override Redirect State: no
Corners: +0+0 -0+0 -0-0 +0-0
-geometry 1280x1024+0+0
D’altra banda tenim la comanda grep que filtra línies de text que continguin un patró determinat. Per exemple:
usuari@computador:mp$ echo -ne "1\n2\n1\n3\n5\n1\n1\n"
1
2
1
3
5
1
1
usuari@computador:mp$ echo -ne "1\n2\n1\n3\n5\n1\n1\n" | grep 1
1
1
1
1
usuari@computador:mp$ echo -ne "1\n2\n1\n3\n5\n1\n1\n" | grep 3
3
Es demana dissenyar una funció anomenada
midesPantallaque posa en les variables d’entornampleialtl’amplada i alçada en píxels respectivament. Guardeu la funció en el fitxer midesp.sh.
Per usar la funció definida escrivim:
usuari@computador:mp $ source midesp.shUn exemple d’us seria:
usuari@computador:mp $ midesPantalla usuari@computador:mp $ echo $ample x $alt 1280 x 1024
En l’exemple anterior, per què si en comptes de fer
source midesp.shfembash midesp.shno trobem midesPantalla?