bash upráva textu, spočítanie riadkov, grep IP, zoradenie IP, uniq
Odstranenie ridkov z textoveho suboru. Zmazanie prvych 51 riadkov zo suboru:
sed '1,51d' text.log > output
Vybratie zo suboru iba IP adresy:
grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}" ip.log
Zoradenie Ip adresy podla postupnosti:
sort -t . -k 3,3n -k 4,4n ip
- -t . : Set field to . (dot) as our IPs separated by dot symbol
- -n : Makes the program sort according to numerical value
- -k opts: Sort data / fields using the given column number. For example, the option -k 2 made the program sort using the second column of data. The option -k 3,3n -k 4,4n sorts each column. First it will sort 3rd column and then 4th column.
Spojenie unikatnych IP adries a vypisanie iba jedneho vyskitu rovakeho zaznamu:
uniq -u