#!/bin/bash ######################################################### # # # This script is to clean the portmon serial logs # # from the non important stuff; it will preserve # # the original log and will open it with you prefered # # text editor (you must set it up on EDITOR) # # # # Licensed under the GNU GENERAL PUBLIC LICENSE 3 # # # # Copyright 2016 Pavel Milanes CO7WT pavelmc@gmail.com # # # ######################################################### # ======================================================= # some vars I always forgot, just for reference # $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS # $NAUTILUS_SCRIPT_SELECTED_URIS # examples of how to handle some usefull things #FILE="/tmp/some_stuff.txt" #DIR=`dirname "$FILE"` # /tmp/ #BASE=${FILE%.*} # /tmp/some_stuff #EXT=${FILE##*.} # txt # ======================================================= # Please set it up for other editor if you like it EDITOR=`which gedit` echo "$NAUTILUS_SCRIPT_SELECTED_URIS" > /tmp/clean_temp for file in $(cat /tmp/clean_temp); do \ file_name=$(echo $file | sed -e 's/file:\/\///g' -e 's/\%20/\ /g') short_file_name=$(echo $file | sed -e 's#.*/##g' -e 's/\%20/\ /g') base=${file_name%.*} final="$base.clean" cat "$file_name" | sed s/"\r"//g | sed s/"\t\t"//g | grep -v "_MASK" \ | grep -v "_COMMSTATUS" | grep -v "_GET_PROPERTIES" \ | sed s/" \t"//g > "$final" $EDITOR "$final" & done rm /tmp/clean_temp exit