0

Can you help me with correct regexp from the sed syntaxis point of view? For now every regexp that i can write is marked by terminal as invalid.

SpaceBucks
  • 25
  • 2

1 Answers1

2

If your log syntax is uniform, use this command

cut -f4 -d\" < logfile | sort -u 

If you want to skip the query string from uniqness, use this

cut -f4 -d\" < logfile | cut -f1 -d\? | sort -u 

Explanation

Filter the output with the cut command, take the 4th field (-f4) using " as separator (-d\"). The same with the second filter, using ? as separator

Francesco Gasparetto
  • 1,819
  • 16
  • 20
  • 1
    [The `cat`s are useless.](/questions/11710552/useless-use-of-cat) You are making some fairly bold assumptions about what the log format looks like; I'm guessing you assume they will be processing Apache logs. – tripleee Feb 18 '20 at 13:59
  • No, i have read all of the user comments, where he put a log line example. Thanks for the cat suggestion, I'll fix it – Francesco Gasparetto Feb 18 '20 at 14:00
  • Can i transform somehow the command from the above for the finding only POST unique records? – SpaceBucks Feb 19 '20 at 10:15
  • Just add | grep POST just before | sort -u, it would become cut -f4 -d\" < logfile | grep POST | sort -u. Learn grep, is very useful, it is just a filter for text parsing, very easy to use – Francesco Gasparetto Feb 19 '20 at 13:34