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 lab con bc
  Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
Laüra
.simpatizzante.

User info:
Registered: Dec 2004
Posts: 14 (0.00 al dì)
Location:
Corso: Informatica
Anno: 3
Time Online: 13:03:02: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
Esercizio lab con bc

Ciao a tutti!
Ho dei problemi a capire come deve essere risolto un esercizio che è stato fatto ad una lezione di laboratorio:

Ottenere il numero totale dei file contenuti nelle directory
/usr/bin e /var (ls, wc, bc)

Qualcuno sa come è stato risolto dal prof a lezione? Bisogna usare bc?

Se qualcuno riuscisse anche a spiegarmi come funziona bc sarebbe il massimo...

Grazie

16-07-2007 17:35
Click Here to See the Profile for Laüra Click here to Send Laüra a Private Message Find more posts by Laüra Add Laüra to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
n3o
tanto c'è SPASS...

User info:
Registered: Oct 2005
Posts: 134 (0.02 al dì)
Location: Brescia
Corso: Informatica Magistrale
Anno:
Time Online: 1 Day, 19:26:05: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

echo $(ls /usr/bin | wc -l) + $(ls /var | wc -l) | bc
bc è una calcolatrice con un proprio linguaggio di scripting che come parametro accetta un file.
$(ls /usr/bin | wc -l) => risultato del comando ls sulla cartella /usr/bin a cui viene applicato un wc -l che ne conta le righe (numero di file nel nostro caso...)
Il parametro per bc invece che da file glielo passiamo con un pipe da un echo che stamperà: <num_file> + <num_file>
Esempio:

ls /usr/bin | wc -l => 315
ls /var | wc -l => 2
echo $(ls /usr/bin | wc -l) + $(ls /var | wc -l) => echo 315 + 2
echo 315 + 2 | bc => 317

Purtroppo non si può scrivere bc 1 + 1 !!!

__________________
The answer is blowing in the wind...

16-07-2007 18:38
Click Here to See the Profile for n3o Click here to Send n3o a Private Message Find more posts by n3o Add n3o to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Laüra
.simpatizzante.

User info:
Registered: Dec 2004
Posts: 14 (0.00 al dì)
Location:
Corso: Informatica
Anno: 3
Time Online: 13:03:02: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Grazie mille!
Cmq cercando su internet ho capito qualcosa di più è sono riuscita anch'io ad arrivare alla soluzione.

16-07-2007 18:46
Click Here to See the Profile for Laüra Click here to Send Laüra a Private Message Find more posts by Laüra Add Laüra to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Toppy84
.amico.

User info:
Registered: Jan 2004
Posts: 21 (0.00 al dì)
Location: Imperia
Corso: informatica triennale
Anno: secondo
Time Online: 1 Day, 7:57:03: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

ciao..io invece avevo trovato questa soluzione..è molto simile

expr $(ls /usr/bin | wc -l) + $(ls /var | wc -l)

va bene uguale o è sbagliata?

16-07-2007 18:51
Click Here to See the Profile for Toppy84 Click here to Send Toppy84 a Private Message Find more posts by Toppy84 Add Toppy84 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
n3o
tanto c'è SPASS...

User info:
Registered: Oct 2005
Posts: 134 (0.02 al dì)
Location: Brescia
Corso: Informatica Magistrale
Anno:
Time Online: 1 Day, 19:26:05: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

:approved: si si è come farei anch'io, ma al prof piace complicarsi la vita... :D

__________________
The answer is blowing in the wind...

16-07-2007 19:38
Click Here to See the Profile for n3o Click here to Send n3o a Private Message Find more posts by n3o Add n3o to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 07:42.    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.043 seconds (69.30% PHP - 30.70% MySQL) con 28 query.