Last active
March 17, 2018 11:20
-
-
Save universome/8cb22000c8c7a0408eea to your computer and use it in GitHub Desktop.
Shuffle contents of a csv file without breaking headers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sed -n '1!p' data.csv | perl -MList::Util=shuffle -e 'print shuffle(<STDIN>);' > shuffled.csv | |
head -1 data.csv >> tmp & cat shuffled.csv >> tmp | |
mv tmp shuffled.csv | |
# You can also use "awk 'NR>1' data.csv", but it will be slower |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment