Outils pour utilisateurs

Outils du site


informatique:linux:awk

Ceci est une ancienne révision du document !


AWK

Quelques liens sur l'utilisation de awk

Tutoriels

Affiche la 9eme colonne, s'il y a 9 colonnes:

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
}'
informatique/linux/awk.1203093733.txt.gz · Dernière modification: 2018/09/06 19:00 (modification externe)