Outils pour utilisateurs

Outils du site


informatique:linux:awk

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentes Révision précédente
Prochaine révision
Révision précédente
informatique:linux:awk [2007/09/26 17:01]
benoit
informatique:linux:awk [2018/09/26 15:25] (Version actuelle)
benoit [Tutoriels]
Ligne 4: Ligne 4:
   * {{http://​www.zikossworld.free.fr/​docwiki/​shells-unix/​awk.html|awk}}   * {{http://​www.zikossworld.free.fr/​docwiki/​shells-unix/​awk.html|awk}}
   * {{awk-wiki.htm|awk}}   * {{awk-wiki.htm|awk}}
 +
 +
 +
 +
 +
 +
 +
 +
  
  
Ligne 9: Ligne 17:
  
 Affiche la 9eme colonne, s'il y a 9 colonnes: Affiche la 9eme colonne, s'il y a 9 colonnes:
-  ​ls -lR /​var/​lib/​mysql/​ |grep -v ^d |awk '{if (NF == 9) {print $9}}'+  awk '{if (NF == 9) {print $9}}' file.txt 
 + 
 +Affiche les 8 premiers caracteres du premier champs 
 +  awk '​{print substr($1,​1,​8)}'​ file.txt 
 + 
 +Afficher du champ 2 au champ de fin : 
 +  echo "​champs1;​champs2;​champs3"​ |awk 'BEGIN { FS = ";"​ } 
 +  { 
 +    for (i = 2; i <= NF; i = i + 1) 
 +    print $i 
 +  }' 
 + 
 +Afficher du champ 2 au champ 4 : 
 +  echo "​champs1;​champs2;​champs3;​champs4;​champs5"​ |awk 'BEGIN { FS = ";"​ } 
 +  { 
 +    for (i = 2; i <= 4; i = i + 1) 
 +    print $i 
 +  ​}'
  
  
 +Affiche **owncloud-9.1.0.tar.bz2** :
 +  echo "​https://​download.owncloud.org/​community/​owncloud-9.1.0.tar.bz2"​ | awk -F"/"​ '​{print $NF}'
 +  ​
 +Affiche **https://​download.owncloud.org/​community/​** :
 +  echo "​https://​download.owncloud.org/​community/​owncloud-9.1.0.tar.bz2"​ || awk -F"/"​ '​{OFS="/";​ $NF=""​}1'​
  
-  cat all-servers-rh-gh.csv |sed '​s/​[Ee][Cc][Aa][Rr][Bb][Ss][Uu][Ll]/​ECUL/​g'​| awk '​{print substr($0,​1,​8)}'​ 
informatique/linux/awk.1190818873.txt.gz · Dernière modification: 2018/09/06 18:59 (modification externe)