S
S
stcmd042362017-03-07 16:30:52
linux
stcmd04236, 2017-03-07 16:30:52

How to get the number of repeating fields in a text?

Hey! And so the text is in the following
message datetime id
form

awk '{print $1}' data.log | sort -t' ' -k3 -rn | uniq -c

But here is one problem: how to get this number of repetitions into a variable? Or are there any other ways?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
stcmd04236, 2017-03-09
@stcmd04236

Thank you! Maybe I didn’t describe what I needed very clearly, but here’s what I wanted

sort -t' ' -k3 data.log | uniq -c | sed 's/^[ \t]*//;s/[ \t]*$//' | awk '{print $1}'

S
Saboteur, 2017-03-07
@saboteur_kiev

awk '{print $1}' data.log | sort -t' ' -k3 -rn | uniq | wc -l

A
Axian Ltd., 2017-03-07
@AxianLTD

wc?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question