The UNIX and Linux Forums  

Go Back   UNIX e Linux Forum > Inizio Forum > Shell scripting e di programmazione
.
google unix.com



Shell scripting e di programmazione Pubblica domande su KSH, CSH, SH, Bash, Perl, PHP, sed, awk e da altri script di shell e linguaggi di scripting shell qui.

Più di UNIX e Linux Forum Argomenti potreste trovare utili
Filo Thread Starter Forum Risposte Ultimo Post
parole wc chaandana UNIX for Dummies Domande & Risposte 5 05-05-2009 11:47 AM
Come contare le occorrenze di una parola specifica in un file in shell bash mskart UNIX for Dummies Domande & Risposte 2 10-30-2008 12:42 PM
Come trovare un count di una parola all'interno di un file bd_joy Shell scripting e di programmazione 9 07-14-2008 10:29 AM
grep tutti i record in un file e di ottenere una parola count-perl meghana Shell scripting e di programmazione 4 02-13-2008 10:06 PM
Conta il numero di eventi da file perticular parola rinku Shell scripting e di programmazione 40 08-10-2007 08:33 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Cerca in questo Thread Rate Thread Modalità di visualizzazione
  #1 (permalink)  
Old 07-09-2009
unx100 unx100 is offline
Utente Registrato
  
 

Iscriviti Data: luglio 2009
Interventi: 19
come a contare una parola in un file

Cari tutti,

ho l'obbligo di contare gli errori e la visualizzazione di un file.
ad es. file1.txt
Codice:
sjdgfjdgfgd ora-0001 sdjgfydh sdukgh7 23
sjdgfjdgfgd ora-0002 sdjgfydhsf34 ew 34v
sjdgfjdgfgd ora-0008 sdjgfydh asdf asdfas 
sjdgfjdgfgd ora-0001 sdjgfydhjkbs ui873
sjdgfjdgfgd ora-0004 sdjgfydh 2876gfen 
sjdgfjdgfgd ora-0002 sdjgfydhj uewiuriue 324987
il risultato sarebbe:
Codice:
Error Code : ORA-0001  Count : 2
Error Code : ORA-0002  Count : 2
Error Code : ORA-0004  Count : 1
Error Code : ORA-0008  Count : 1
Ho scritto un prog. come qui di seguito e sta lavorando bene. vorrei sapere che sono tutti in modo semplice per scrivere il prog. Nuovo modo di unix non è sicuro di altri modi.
Grazie in anticipo.

Codice:
#!/bin/sh
echo "Enter filename..."
read name
cd /test/unix
cat $name | while read line
do
echo "$line" > tmpj
cat "tmpj" | egrep -c ora- > tmpk
if [ `cat tmpk` -gt 0 ]
then 
cat tmpj | sed 's/.*\(ora-.....\).*/\1/' >> tmpl
fi
done
rm tmpj
rm tmpk
for var1 in `cat tmpl`
do
echo "$var1" > tmpj
cat tmpl | egrep -c `cat tmpj` > tmpk
if [ `cat tmpk` -gt 0 ]
then
echo "Error Code : "$var1"  Count : `cat tmpk`"
sed "/$var1/d" tmpl > tmpm
mv tmpm tmpl
fi
done
rm tmpj
rm tmpk
rm tmpl

Ultimo a cura di vgersh99; al 07/09/2009 12:11 PM.. Motivo: tag del codice, PLEASE!
 

Segnalibri

Thread Tools Cerca in questo Thread
Cerca in questo Thread:

Ricerca Avanzata
Modalità di visualizzazione Vota questo thread
Vota questo thread:

Distacco regolamento
Tu non può post nuovo thread
Tu non può inviare una risposta
Tu non può postare allegati
Tu non può modificare i tuoi post

BB codice è Su
Smilies sono Su
[IMG] codice Su
Codice HTML è Chiuso
Trackbacks sono Su
Pingbacks sono Su
Refbacks sono Su




Tutti gli orari sono GMT -4. La data di oggi è 05:09 PM.


Powered by: vBulletin, Copyright © 2000 - 2006, Jelsoft Enterprises Limited. Traduzioni Powered by .
vBCredits v1.4 Copyright © 2007 - 2008, PixelFX Studios
UNIX e Linux Forum Content Copyright © 1993-2009. Tutti i diritti Reserved.Ad di gestione da RedTyger

Contenuti pertinenti URL da vBSEO 3.2.0