We need to redirect the output of a query to .csv file each containing a specified number of lines.Then we should zip these files and send as attachment using mutt command.
We tried using
split -l 500 query_output.txt outputfile
Since we are not sure about the exact number of files even if we use gzip outputfile*, how will we send all the zipped files as attachment using mutt command?
---------- Post updated at 06:04 AM ---------- Previous update was at 02:34 AM ----------
Solved!
tail -n +2 file.txt | split -l 4 - split_
for file in split_*
do
head -n 1 file.txt > tmp_file
cat $file >> tmp_file
mv -f tmp_file $file
done
Here, the header file is added as first line in all the splitted files.