Created
May 27, 2014 01:33
-
-
Save burdenless/4b96492e77e3a949ce1c to your computer and use it in GitHub Desktop.
BASH script to process all logfile headers in a given dir
This file contains 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
#!/bin/bash | |
# | |
# Purpose: Analyze header of logfiles or magic number of other files | |
# | |
# Text color variables | |
txtund=$(tput sgr 0 1) # Underline | |
txtbld=$(tput bold) # Bold | |
bldred=${txtbld}$(tput setaf 1) # red | |
bldblu=${txtbld}$(tput setaf 4) # blue | |
bldwht=${txtbld}$(tput setaf 7) # white | |
txtrst=$(tput sgr0) # Reset | |
info=${bldwht}*${txtrst} # Feedback | |
pass=${bldblu}*${txtrst} | |
warn=${bldred}*${txtrst} | |
ques=${bldblu}?${txtrst} | |
echo "$(tput setaf 2)############################## | |
### File Header Analyzer ### | |
### ### | |
### Author: Pendrak0n ### | |
##############################$(tput sgr0)" | |
printf "\n" | |
FILES_PATH="$1*" | |
if [[ $1 == "" ]]; | |
then | |
echo -e "$(tput setaf 1)[!] Error. No dir path provided\n$(tput sgr0)" | |
echo "[*] usage: ./logheader.sh <dir path of logfiles to process>" | |
exit | |
else | |
$FILES_PATH = $1 | |
fi | |
for f in $FILES_PATH | |
do | |
echo "$(tput setaf 3)[*] Processing $f...$(tput sgr0)" | |
# take action on each file. | |
head -n 1 $f | |
printf '\n' | |
done | |
echo "$(tput setaf 2)[+] All files processed.$(tput sgr0)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment