Je suis nouveau à AWK, j'ai quelques idées de base dans AWK. Je veux supprimer les doublons dans un fichier, par exemple:en utilisant AWK comment supprimer ce genre de doublons?
0008.ASIA. NS AS2.DNS.ASIA.CN.
0008.ASIA. NS AS2.DNS.ASIA.CN.
ns1.0008.asia. NS AS2.DNS.ASIA.CN.
www.0008.asia. NS AS2.DNS.ASIA.CN.
anish.asia NS AS2.DNS.ASIA.CN.
ns2.anish.asia NS AS2.DNS.ASIA.CN
ANISH.asia. NS AS2.DNS.ASIA.CN.
C'est un exemple de fichier, à partir qu'utiliser cette commande, je suis sortie comme ceci:
awk 'BEGIN{IGNORECASE=1}/^[^ ]+asia/ { gsub(/\.$/,"",$1);split($1,a,".")} length(a)==2{b[$1]++;}END{for (x in b)print x}'
0008.ASIA .
anish.asia.
ANISH.asia
Mais je veux sortie comme ça
008.ASIA
anish.asia
ou
008.ASIA
ANISH.asia
Comment puis-je supprimer ce genre de doublons?
Merci à l'avance Anish kumar.V
Merci pour votre reponse immédiate, En fait, j'écrit un script complet en bash, maintenant, je suis en phase finale. Comment appeler python dans ce :-(
#!/bin/bash
current_date=`date +%d-%m-%Y_%H.%M.%S`
today=`date +%d%m%Y`
yesterday=`date -d 'yesterday' '+%d%m%Y'`
RootPath=/var/domaincount/asia/
MainPath=$RootPath${today}asia
LOG=/var/tmp/log/asia/asiacount$current_date.log
mkdir -p $MainPath
echo Intelliscan Process started for Asia TLD $current_date
exec 6>&1 >> $LOG
#################################################################################################
## Using Wget Downloading the Zone files it will try only one time
if ! wget --tries=1 --ftp-user=USERNAME --ftp-password=PASSWORD ftp://ftp.anish.com:21/zonefile/anish.zone.gz
then
echo Download Not Success Domain count Failed With Error
exit 1
fi
###The downloaded file in Gunzip format from that we need to unzip and start the domain count process####
gunzip asia.zone.gz > $MainPath/$today.asia
###### It will start the Count #####
awk '/^[^ ]+ASIA/ && !_[$1]++{print $1; tot++}END{print "Total",tot,"Domains"}' $MainPath/$today.asia > $RootPath/zonefile/$today.asia
awk '/Total/ {print $2}' $RootPath/zonefile/$today.asia > $RootPath/$today.count
a=$(< $RootPath/$today.count)
b=$(< $RootPath/$yesterday.count)
c=$(awk 'NR==FNR{a[$0];next} $0 in a{tot++}END{print tot}' $RootPath/zonefile/$today.asia $RootPath/zonefile/$yesterday.asia)
echo "$current_date Count For Asia TlD $a"
echo "$current_date Overall Count For Asia TlD $c"
echo "$current_date New Registration Domain Counts $((c - a))"
echo "$current_date Deleted Domain Counts $((c - b))"
exec >&6 6>&-
cat $LOG | mail -s "Asia Tld Count log" [email protected]
Dans ce
awk '/^[^ ]+ASIA/ && !_[$1]++{print $1; tot++}END{print "Total",tot,"Domains"}' $MainPath/$today.asia > $RootPath/zonefile/$today.asia
dans cette partie seulement maintenant que je suis à la recherche comment obtenir les valeurs distinctes si des suggestions en utilisant AWK est mieux pour moi. Merci encore une fois pour votre réponse immédiate.
Désolé, mais ajoutez que tout votre script Bash posté ici ne clarifie pas vraiment les choses. Pouvez-vous réduire votre question à un petit exemple plus une déclaration du problème que vous rencontrez actuellement? –
Salut maintenant Problème est mon premier poste, je viens de montrer ici que j'ai écrit un script ... est-il possible d'utiliser AWK lui-même et je n'ai pas beaucoup d'idée en python .. –
Pouvez-vous nettoyer votre question? Cela aiderait beaucoup. –