Skip to content

Instantly share code, notes, and snippets.

@diegogslomp
Created September 25, 2016 14:53
Show Gist options
  • Save diegogslomp/159086484dabb5f3fe5de4f372405c8a to your computer and use it in GitHub Desktop.
Save diegogslomp/159086484dabb5f3fe5de4f372405c8a to your computer and use it in GitHub Desktop.
Script to filter mac from OCS exported file and prints OFFICESCAN exported file without mac matched lines
#!/bin/bash
# Script to filter mac from OCS exported file and prints
# OFFICESCAN exported file without mac matched lines
# Need csvkit installed: pip install csvkit
set -e
OFFICESCAN="OfficeScan agent listing.csv"
OCS="export.csv"
MACLIST="ocsmaclist.tmp"
OUTPUT="output.tmp"
cp "${OFFICESCAN}" "${OUTPUT}"
sed 1d "${OCS}" | awk -F ";" '{print $7}' | tr ':' '-' | sed '/^$/d' > "${MACLIST}"
while IFS= read -r OCSMAC; do
sed -i "/${OCSMAC}/d" "${OUTPUT}"
done < "${MACLIST}"
csvcut -c 2,3,21,60 "${OUTPUT}"
rm "${MACLIST}"
rm "${OUTPUT}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment