User Tools

Site Tools


informatique:linux:awk

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
informatique:linux:awk [2019/06/06 07:26] pteuinformatique:linux:awk [2019/06/06 09:21] – fonction trim pteu
Line 188: Line 188:
 echo -e "toto\ntoto\n" | awk '/toto/ {print; exit}' echo -e "toto\ntoto\n" | awk '/toto/ {print; exit}'
  toto  toto
 +</code>
 +
 +  * émuler la fonction trim (efface les espaces avant et après une chaine) :
 +<code bash>
 +echo -e "toto   :titi\n   tata:tutu" | \
 + awk -F\: '{ sub(/^[ \t\r\n]+/, "", $1);sub(/[ \t\r\n]+$/, "", $1);print "\""$1"\""}'
 </code> </code>
informatique/linux/awk.txt · Last modified: 2022/04/13 13:03 by pteu