vim Search and Replace
Had some grief tonight with a search and replace string.
I am backing up some videos to an external HDD and some are files and some are folders, so I’ve created a rsync script which uses a include.txt file.
rsync script is as follows:
rsync -avr --progress --files-from=include.txt / /media/Ext\ Storage
Then in my
include.txt I have the following:
Which I obtained from doing a find dump into a file
find /data/videos/ > include.txt
Except for the includes.txt, it the directories need to have the trailing slash.
I first off tried to create a regex search and replace in vim which found all rows that didn’t have a file extension. I managed to create a expression which DID find them but couldn’t work out how to then wrap that in a NOT.
So I thought screw it, I’ll add a trailing slash / to every row then strip them out and after 45min of screwing around I finally got it.
I used /c just to make sure it wasn’t going to go crazy, and it didn’t!
It’s probably not the most elegant or efficient but I have a sense of achievement all the same 🙂