Created
August 2, 2017 17:22
-
-
Save WoodProgrammer/dcbb2fc675187272046f19e3777a708c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ##### HEAD_COMMAND | |
| #!/bin/bash | |
| x=$1 | |
| i=0 | |
| while read line | |
| do | |
| echo $line | |
| ((i++)) | |
| if [ $i -gt $x ] | |
| then | |
| exit | |
| fi | |
| done < test.log | |
| ########Tail_COmmand | |
| #!/bin/bash | |
| word_count=$(wc -l test.log |awk '{print $1}') | |
| line_count=$2 | |
| stop_word=$[ $word_count - $line_count ] | |
| i=0 | |
| junk=0 | |
| while read line | |
| do | |
| if [ $i -le $stop_word ] | |
| then | |
| junk=$[junk+1] | |
| else | |
| echo $line | |
| fi | |
| i=$[i+1] | |
| done < test.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment