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 Monga
  Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
Cic
.fedelissimo.

User info:
Registered: Jul 2009
Posts: 44 (0.01 al dì)
Location:
Corso:
Anno:
Time Online: 16:21:01: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
Esercizio Monga

Ciao, qualcuno saprebbe dirmi come fare questo esercizio?

Trovare i file che hanno numero di caratteri dispari nel nome.

Ho provato con:

find / -type f | while read line; do wc -m $line | awk '{if(($line%2)!=0) print $line};
done;

e con:

find / -type f -printf "%f\n" | wc -m $nome | awk '{if(($nome%2)!=0) print $nome}'

ma sembra non andare. Curiosamente se lo faccio sui fali .c sembra funzionare, ma in questi modi stampa anche file con numero di caratteri pari nel nome.

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

User info:
Registered: Jun 2016
Posts: 2 (0.00 al dì)
Location:
Corso: Informatica
Anno: 2016
Time Online: 4:54:21 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Ciao, io l' ho fatto con un programmino da eseguire da bash :)

#trovare i file che hanno un numero di caratteri dispari nel nome
mycounter=0
lstarget='/usr/include/'
for i in `ls $lstarget | grep -v ^d | cut -d '.' -f1`; do
nomefile=$(echo $i | cut -d '.' -f1)
ncaratteri=$(echo $i | wc -m)
ncaratteri=`expr $ncaratteri - 1`
test=$(( $ncaratteri % 2 ))
if [ $test -ne 0 ] ; then
echo $nomefile $ncaratteri
fi
done

02-06-2017 09:26
Click Here to See the Profile for guidodl Click here to Send guidodl a Private Message Find more posts by guidodl Add guidodl to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Cic
.fedelissimo.

User info:
Registered: Jul 2009
Posts: 44 (0.01 al dì)
Location:
Corso:
Anno:
Time Online: 16:21:01: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Ciao, grazie per la risposta :)
Una domanda, ma fi e done non devono essere seguiti da un ";"?

02-06-2017 11:17
Click Here to See the Profile for Cic Click here to Send Cic a Private Message Find more posts by Cic Add Cic to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
guidodl
.novellino.

User info:
Registered: Jun 2016
Posts: 2 (0.00 al dì)
Location:
Corso: Informatica
Anno: 2016
Time Online: 4:54:21 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

A quanto pare no. Infatti se lo salvi in un file di tipo .sh e lo esegui con bash <nomefile> funziona

03-06-2017 10:12
Click Here to See the Profile for guidodl Click here to Send guidodl a Private Message Find more posts by guidodl Add guidodl to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Cic
.fedelissimo.

User info:
Registered: Jul 2009
Posts: 44 (0.01 al dì)
Location:
Corso:
Anno:
Time Online: 16:21:01: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Ok proverò, grazie ancora. :) Perché se lo eseguo con ./nomefile mi dà degli errori.

03-06-2017 11:03
Click Here to See the Profile for Cic Click here to Send Cic a Private Message Find more posts by Cic Add Cic to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 17:09.    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.030 seconds (82.04% PHP - 17.96% MySQL) con 27 query.