wiki:blog:grep_and_awk_like_sql
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | wiki:blog:grep_and_awk_like_sql [2019/01/05 13:06] (current) – created kpc | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== grep and awk like SQL ====== | ||
+ | easy to understand if map *nix console tools to SQL commands.Its usefull to analyse big files with strict stucture, like logs or dumps. | ||
+ | |||
+ | select * from file where column = " | ||
+ | cat ./ | ||
+ | |||
+ | select sum(numbers) from file where column = " | ||
+ | cat ./ | ||
+ | |||
+ | select avg(numbers) from file where column = " | ||
+ | cat ./ | ||
+ | |||
+ | select count(*) from file group by column | ||
+ | cat ./ | ||
+ | |||
+ | with perl or awk analyzing columns can be extracted from source file for further calculating. | ||
+ | |||
+ | group by date and calculating any speed/avg | ||
+ | |||
+ | for example your log file begin with date: 11: | ||
+ | gouping by date can be done by cutting chars from end | ||
+ | seconds: cat ./ | ||
+ | minutes: cat ./ | ||
+ | | ||
+ | original url: http:// | ||
+ |
wiki/blog/grep_and_awk_like_sql.txt · Last modified: 2019/01/05 13:06 by kpc