Welcome to the Linux Foundation Forum!

Zeek to CSV bash script help

I am trying to work with a script that was on github - but I am having problems with it. Does anyone see anything wrong with 1) my replacement for FILEPATH and OUTPATH from 2) the template?

1) MY VARIABLE Edits to the template in #2 below

!/bin/bash

bro_in_data=/"path_to_the_input_logs_directory"/ #path to input logs directory
bro_out_csv=/"path_to_the_output_logs_directory"/ #path to output logs directory

echo "Transforming to csv ..."
for log in $(ls $bro_in_data); do

FILEIN=$bro_in_data$log
FILEOUT=$bro_out_csv$log

# -d option in zeek-cut convert time values into 
# human-readable format. %Y-%m-%dTH%:%M:%S
cat $FILEIN | zeek-cut -c -d > $FILEOUT

# If you don´t want to use zeek-cut, comment the line above
# and uncomment the line below
#sed -i '$d' $FILEOUT

# Remove line 8
sed -i '8d' $FILEOUT

# Remove lines 1 to 6
sed -i '1,6d' $FILEOUT

# Delete #fields
sed -i 's/#fields\t//' $FILEOUT

# Replace '\t' with ','
sed -i 's/\t/,/g' $FILEOUT

done
echo "Done"

2) TEMPLATE

!/bin/bash

FILEPATH=/"path_to_the_input_logs_directory"/ #path to input logs directory
OUTPATH=/"path_to_the_output_logs_directory"/ #path to output logs directory

echo "Transforming to csv ..."
for log in $(ls $FILEPATH); do

FILEIN=$FILEPATH$log
FILEOUT=$OUTPATH$log

# -d option in zeek-cut convert time values into 
# human-readable format. %Y-%m-%dTH%:%M:%S
cat $FILEIN | zeek-cut -c -d > $FILEOUT

# If you don´t want to use zeek-cut, comment the line above
# and uncomment the line below
#sed -i '$d' $FILEOUT

# Remove line 8
sed -i '8d' $FILEOUT

# Remove lines 1 to 6
sed -i '1,6d' $FILEOUT

# Delete #fields
sed -i 's/#fields\t//' $FILEOUT

# Replace '\t' with ','
sed -i 's/\t/,/g' $FILEOUT

done
echo "Done"

Categories

Upcoming Training