Systemy operacyjne - lab. 6-7 ======================================================== 1- przekierowanie i/o stdin =0 stdout =1 stderr =2 i/o procesu cat filter concatenate, C-D cat -n < f1 > f2 < not necessary, -n numbers line cat f* > f3 cat >> f cat << keyword input till keyword split -b 100k dane.zip dane. split file into dane.aa dane ab .. (each <100KB) cat a b c 2> err see content of files but error messages (file not found) to file err cat a b c > x 2> /dev/null cat a b c > abcErr 2>&1 (2>abcErr isn't correct) cat f1 - f2 > f "-" czytaj z stdin cat f1 /dev/stdin f2 > f same as above 2- potoki ls -l /usr/bin | more cat f | head -n 12 | tail -n 8 od 5 do 12 linii head -n 12 f | tail -n 8 same as above head -n 10 f | tail -n 1 | head -c 5 5 pierwszych znakow w 10 linii tail -f log find /usr -name "*.bin" | head -n 5 find /usr -name "*.bin" 2> /dev/null | head -n 5 find /usr -name "*.bin" 2>&1 | head -n 5 find /usr -name "*.bin" | tee f | tail -5 all files to f, last 5 on stdout find /usr -name "*.bin" | tee -a f | tail -5 append to f 3- inne filtry sort f sort -n f numeric ls -l | sort -n +4 wg rozmiaru pliku: +4 wycina pierwsze 4 kolumny, oddzielone spacja lub tab sort -t: -n +2 /etc/passwd -t: zmienia sep kolumn na : -k5,5 5-ta kolumna (POSIX standard) -k5,6 5 i 6-ta kolumna -k5 od 5-ej do konca -f confuses small and big letters -r reverse sorting getent passwd wypisuje tylko uzytkownikow z passwd uniq f usuwa powtarzajace sie, sasiadujace linie sort f | uniq sort -u f same as above sort f | uniq -u unique lines in f sort f | uniq -d duplicate lines in f wc count -l lines, -w words, -c chars ls -l | grep ^- | wc -l count files bc filtr kalkulator cat f | tr ab AB translate a to A, b to B (tr wymaga np. cat) cat f | tr ab A translate a to A, b to A cat f | tr a-c '?' | tr -d '\t\n' delete znaki tab i nowej lini cat f | tr -s ' ' squeeze spacje do jednej cat f | tr -s '\t' ' ' squeeze spacje lub tab do jednej spacji (zob. inne znaki specjalne w man tr) cut select column, podajac numer (-f) lub przesuniecie w znakach (-c) lub bajtach (-b) wzgledem pocz linii; kolumny rozdzielone tab, lub 'znak' piszac -d znak (d=delimiter) cut -f1,3-5,7- f zakresy (np. od siodmej do konca) ls -l | tr -s ' ' | cut -f 5,9 -d ' ' nazwa i rozmiar pliku ls -l | tr -s ' ' '\t' | cut -f 5,9 nazwa i rozmiar pliku (ladniejszy wydruk) co robi ponizsza komenda? who | cut -f1 -d " " | sort | uniq | wc -l biezacy uzytkownicy