0

I was trying to copy the content of a huge file (10GB) to another skipping the first line (as in head -n1). I tried multiple ways of head, tail, awk and sed. Settled on using tail -n+2 > ./xab.1

see link1 link2 link3. But the processing is taking a log time. More than that it takes to cp.

I just want to blindly copy the content, thatz all. So I think dd will do the job but I'm at loss implementing it. Any help?

Well, to give more context the file is CSV and so I think doing, dd if=/dev/zero of=/path/to/file bs=1 seek=1 count=<<length(head -n1 /path/to/file)>> conv=notrunc should work.

But how to make it working??

EDIT: So here is what I've come up with so far, (yes, I know i'm going to loose a few records. But that doesn't matter)

#!/bin/bash
echo "Initiating xaa." `date`
head -n3 /stage/csv/dev/data/csv_huge/xaa > /stage/csv/dev/data/csv_huge/csv/header
tail -n3 /stage/csv/dev/data/csv_huge/xbc > /stage/csv/dev/data/csv_huge/csv/trailer
sed -i '$ d' /stage/csv/dev/data/csv_huge/xaa
cat /stage/csv/dev/data/csv_huge/csv/trailer >> /stage/csv/dev/data/csv_huge/xaa
mv /stage/csv/dev/data/csv_huge/xaa /stage/csv/dev/data/csv_huge/csv/xaa
echo "Completed xaa." `date`
sed -i 1d /stage/csv/dev/data/csv_huge/xab
sed -i '$ d' /stage/csv/dev/data/csv_huge/xab
cat /stage/csv/dev/data/csv_huge/csv/header /stage/csv/dev/data/csv_huge/xab > /stage/csv/dev/data/csv_huge/csv/xab
cat /stage/csv/dev/data/csv_huge/csv/trailer >> /stage/csv/dev/data/csv_huge/csv/xab
rm -f /stage/csv/dev/data/csv_huge/xab
echo "Completed xab." `date`
sed -i 1d /stage/csv/dev/data/csv_huge/xbc
cat /stage/csv/dev/data/csv_huge/csv/header /stage/csv/dev/data/csv_huge/xbc > /stage/csv/dev/data/csv_huge/csv/xbc
echo "Completed xbc." `date`

0 Answers0