Count occurrence of character in field and print in a new field
%%%%%
|
Something like:
Code:
awk 'BEGIN{OFS="|"}{if(NR == 1)$6 = "Field6";else $6 = 0}NR > 1 && $4 ~ /x/{$6 = split($4,_,"x") - 1}1' file |
Thanks grail !
I see what you mean. It is a bit like using the character I am looking for as FS and count the number of field. Like: Code:
awk 'BEGIN {FS="x"} {print $0, NF-1}' file I didn't know that the split option returns the number of array by default. Thanks again grail ! |
awk: sort variable value and assign a name accordingly
error
|
error???? Would you like to provide more information?
|
No no, it works !
I didn't write on the good thread, my mistake ! |
All times are GMT -5. The time now is 08:46 AM. |