Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- foo
- bar
- foobar
- barfoo
- last
- line
- foo
- bar
- foobar
- $ tac file | sed '1,3d' | tac
- foo
- bar
- foobar
- $ tac file | awk 'NR==1{next}NR==2{next}NR==3{next}1' | tac
- foo
- bar
- foobar
- ... | awk '{l[NR] = $0} END {for (i=1; i<=NR-3; i++) print l[i]}'
- ... | awk '{if (a) print a; a=b; b=c; c=$0}'
- awk -v n=$(($(wc -l < file) - 3)) 'NR<n' file
- $ seq 6 | head -n-3
- 1
- 2
- 3
- awk 'NR>n{print A[NR%n]} {A[NR%n]=$0}' n=3 file
- Line 1 -> A[1]
- Line 2 -> A[2]
- Line 3 -> A[0]
- Line 4 -> A[1]
- Line 5 -> A[2]
- ...
- awk '{if(NR==FNR){c++}else if(FNR<=c-3){print}}' file file
- for i in {500000..1000000}; do
- echo "The quick brown fox jumped over the lazy dog $i" >> file;
- done
- $ for i in {1..10}; do (
- time awk '{if(NR==FNR){c++}else if(FNR<=c-3){print}}' file file > /dev/null ) 2>&1 |
- grep -oP 'real.*?mK[d.]+';
- done | awk '{k+=$1}END{print k/10" seconds"}';
- 0.4757 seconds
- $ for i in {1..10}; do (
- time awk '{l[NR] = $0} END {for (i=1; i<=NR-3; i++) print l[i]}' file > /dev/null ) 2>&1 |
- grep -oP 'real.*?mK[d.]+';
- done | awk '{k+=$1}END{print k/10" seconds"}';
- 0.5347 seconds
- head -n -3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement