Dsy Network www | forum | my | didattica | howto | wiki | el goog | stats | blog | dona | rappresentanti
Homepage
 Register   Calendar   Members  Faq   Search  Logout 
.dsy:it. : Powered by vBulletin version 2.3.1 .dsy:it. > Didattica > Corsi N - Z > Sistemi operativi I > [esercizio shell]
  Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
Elisabeth
dsy core staff

User info:
Registered: Jul 2014
Posts: 22 (0.01 al dì)
Location: Lake of Como
Corso: Informatica
Anno: III anno
Time Online: 6:57:11 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
[esercizio shell]

Sono alle prese con questo esercizio:
trovare l'utente con il maggior numero di file sul sistema
che mi sembrava fattibilissimo ma mi sta mandando in crisi.

Io lo risolverei così:


NFILE=0
for USER in $(cut /etc/passwd -d : -f 1)
do
FILE=$(find / -type f -user $USER | wc -l)
if (($FILE > $NFILE))
then
NFILE=$FILE
NUSER=$USER
fi
done
echo "L'utente $USER ha il maggior numero di file sul sistema, pari a $NFILE"

Ma mi da errore..qualche idea su cosa c'è di sbagliato?

04-09-2014 11:46
Click Here to See the Profile for Elisabeth Click here to Send Elisabeth a Private Message Find more posts by Elisabeth Add Elisabeth to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Cronovirus
dsy core staff

User info:
Registered: Jun 2012
Posts: 471 (0.10 al dì)
Location:
Corso: Magistrale in Informatica
Anno: 2
Time Online: 4 Days, 2:45:03: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Secondo me stai sbagliando sintassi nella condizione dell'if! guarda qui http://stackoverflow.com/questions/...thmetic-in-bash

04-09-2014 14:42
Click Here to See the Profile for Cronovirus Click here to Send Cronovirus a Private Message Find more posts by Cronovirus Add Cronovirus to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Elisabeth
dsy core staff

User info:
Registered: Jul 2014
Posts: 22 (0.01 al dì)
Location: Lake of Como
Corso: Informatica
Anno: III anno
Time Online: 6:57:11 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Lo pensavo anche io, però provando a testare solamente l'if con le ((..)) funzionava :(

Alla fine ho optato per questa soluzione:

NFILE=0
for USER in $(cut /etc/passwd -d : -f 1)
do
FILE=$(find / -type f -user $USER | wc -l)
if [ $FILE -gt $NFILE ]
then
NFILE=$FILE
NUSER=$USER
fi
done
echo "L'utente $USER ha il maggior numero di file sul sistema, pari a $NFILE"

04-09-2014 15:04
Click Here to See the Profile for Elisabeth Click here to Send Elisabeth a Private Message Find more posts by Elisabeth Add Elisabeth to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Cronovirus
dsy core staff

User info:
Registered: Jun 2012
Posts: 471 (0.10 al dì)
Location:
Corso: Magistrale in Informatica
Anno: 2
Time Online: 4 Days, 2:45:03: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

ma aspetta: che errore ti dava?

04-09-2014 15:37
Click Here to See the Profile for Cronovirus Click here to Send Cronovirus a Private Message Find more posts by Cronovirus Add Cronovirus to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Elisabeth
dsy core staff

User info:
Registered: Jul 2014
Posts: 22 (0.01 al dì)
Location: Lake of Como
Corso: Informatica
Anno: III anno
Time Online: 6:57:11 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

aaa non mi ricordo purtroppo.
Ma va beh, ormai il laboratorio è andato :)

07-09-2014 09:23
Click Here to See the Profile for Elisabeth Click here to Send Elisabeth a Private Message Find more posts by Elisabeth Add Elisabeth to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
rogerino
.novellino.

User info:
Registered: Jun 2010
Posts: 2 (0.00 al dì)
Location:
Corso:
Anno:
Time Online: 13:10:02: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

mi sapete dire come si risolve questo esercizio:

copiare tutti i file da /usr/bin nella directory corrente cambiando l'estensione da .h a .bak??

09-02-2015 13:14
Click Here to See the Profile for rogerino Click here to Send rogerino a Private Message Find more posts by rogerino Add rogerino to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
giuscri
.novellino.

User info:
Registered: Mar 2015
Posts: 5 (0.00 al dì)
Location:
Corso:
Anno:
Time Online: 2:07:49 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by rogerino
mi sapete dire come si risolve questo esercizio:

copiare tutti i file da /usr/bin nella directory corrente cambiando l'estensione da .h a .bak??

Per i posteri, una possibile soluzione:
code:
cp -r /usr/bin /tmp/_bin; for FILENAME in $(find /tmp/_bin -type f|egrep "\.h$"); do mv $FILENAME $(echo $FILENAME|sed -r "s/\.h$/.bak/"); done; cp -r /tmp/_bin/* .

23-07-2015 13:28
Click Here to See the Profile for giuscri Click here to Send giuscri a Private Message Find more posts by giuscri Add giuscri to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 09:46.    Post New Thread    Post A Reply
  Last Thread   Next Thread
Show Printable Version | Email this Page | Subscribe to this Thread | Add to Bookmarks

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is ON
 

Powered by: vBulletin v2.3.1 - Copyright ©2000 - 2002, Jelsoft Enterprises Limited
Mantained by dsy crew (email) | Collabora con noi | Segnalaci un bug | Archive | Regolamento | Licenze | Thanks | Syndacate
Pagina generata in 0.036 seconds (78.78% PHP - 21.22% MySQL) con 26 query.