I'm cleaning up a CVS repo before migration to git. As part of the preparation I need to find (and possibly remove) any folders which ONLY contain an Attic
folder.
My unix-fu is not strong, but here's what I attempted, which doesn't work, but hopefully conveys the intent.
shopt -s globstar
for file in **/*
do
if [ -d "$file" ];then
if [`ls | wc -l` == 1 && `ls Attic | wc -l` == 1]; then
((echo Attic-only folder))
fi
fi
done
The second part to this is to then find any folders (or folder chains, rather) that are empty.
For example, if /foo/bar/Attic
is removed, and /foo/bar
are now both empty, lets kill that part of the tree too.
Background: I'm trying to clean up a CVS repository for migration to git. CVS creates an Attic
folder for deleted files. Over the last 10 years some Bad Things have happened. I am fully aware of the risks and implications. I have backed up my data and I'm working on a copy.
Attic
folders break the history of the repository? – Kusalananda Aug 02 '16 at 10:21cvs up -P
), so I think you may be doing more harm than good with removing them. Try importing into Git without removing them and see what happens first. This may be a no-problem. – Kusalananda Aug 02 '16 at 10:26CVS
directories? – Satō Katsura Aug 02 '16 at 10:27,v
files and anAttic
folder, it can stay. If the only contents of a folder is the attic folder, it can go. – Denham Coote Aug 02 '16 at 10:33