Skip to content

Instantly share code, notes, and snippets.

@babarot
Created June 12, 2014 12:07
Show Gist options
  • Save babarot/7dd8f999792d9efcdb81 to your computer and use it in GitHub Desktop.
Save babarot/7dd8f999792d9efcdb81 to your computer and use it in GitHub Desktop.
#!/bin/bash
declare test_log=~/.safe/log
OLDIFS=$IFS
IFS=$'\n'
array_front=( $(tail -n "${1:-10}" $trash_log | awk '{print $1,$2}' | sed "s $HOME ~ g") )
array_center=( $(tail -n "${1:-10}" $trash_log | awk '{print $3}' | sed "s $HOME ~ g") )
array_rear=( $(tail -n "${1:-10}" $trash_log | awk '{print $4}' | sed "s $HOME ~ g") )
declare max=`
for((I = 0; I < ${#array[*]}; ++I)); do
echo "${#array[I]}"
done | sort -nr | head -1`
for ((I = 0; I < ${#array[*]}; ++I))
do
diff+=(`expr "$max" - ${#array[I]}`)
for ((J = 0; J < ${diff[I]}; ++J))
do
array[I]+=" "
done
done
for ((I = 0; I < ${#array[*]}; ++I))
do
echo -e "${array_a[I]}\t${array[I]}\t${array_e[I]}"
done
IFS=$OLDIFS
exit 0
#!/bin/bash
declare test_log=~/.safe/log
OLDIFS=$IFS
IFS=$'\n'
array_front=( $(tail -n "${1:-10}" $trash_log | awk '{print $1,$2}' | sed "s $HOME ~ g") )
array_center=( $(tail -n "${1:-10}" $trash_log | awk '{print $3}' | sed "s $HOME ~ g") )
array_rear=( $(tail -n "${1:-10}" $trash_log | awk '{print $4}' | sed "s $HOME ~ g") )
declare max=`
for((I = 0; I < ${#array[*]}; ++I)); do
echo "${#array[I]}"
done | sort -nr | head -1`
for ((I = 0; I < ${#array[*]}; ++I))
do
printf "%s\t%-${max}s\t%s\n" ${array_a[I]} ${array[I]} ${array_e[I]}
done
IFS=$OLDIFS
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment