I have files that look like this:
asdasadsdasdas
dasdasdasdasd
asdas
dasd
asdas
das
das
das
das
das
#SHUFFLE_MARK_START
das
d
das
das
dasd
asd
asdas
das
das
afs
sf
#SHUFFLE_MARK_END
fas
fas
fas
fas
fas
fas
fas
fas
I want to shuffle only part of file between two markers - #SHUFFLE_MARK_START and #SHUFFLE_MARK_END, shuffle markers can be any string I want, they just need to be unique filewise, any ideas how to do it in bash so it's efficient?
I already tried to do it by doing something like
cat file | grep -P '.+#SHUFFLE_MARK_START' > start
cat file | grep -P '#SHUFFLE_MARK_START.+#SHUFFLE_MARK_FINISH' | shuff | > middle
cat file | grep -P '#SHUFFLE_MARK_FINISH.+' > end
echo start middle end > shuffled
but it's pretty slow for big files, commands above may be slightly wrong as I'm typing them from memory just to show idea