One can do many tedious tasks in linux easily using its commands, one such task can be:
Move all unwanted files in a code base to a directory.
a) either one can use 'svn st' command and find all '?' files and manually copy and move them to other dir or
b) use power full linux utilities do it for you.
#svn st | egrep -v 'M|X|A|cscope|tags|Performing' | awk -F" " '{print $2}' | xargs -I {} mv {} not_needed/
i) 'svn st' list all files like modified, new etc.
In above command we carefully have to ignore display of modified files
'M' -modified
'A' - newly added
'cscope' - cscope tags
'tags' - ctags
'X' - unknow type and any other unwanted types like file name starting with 'Performing' etc
ii) awk -F" " '{print $2}' --- display filenames
iii) xargs -I {} mv {} not_needed/
[ {} is a placeholder meaning "the current argument". (You can use xxx or yyy or any other string instead of {} if you want, as well, and it'll do exactly the same thing.) -I implies -n1, because you want to act on each file individually. ]
Courtesy - http://www.linuxplanet.com/linuxplanet/tutorials/6522/3
You are done, the above command moves all unwanted files to folder name not_needed in above case.
Caution: Above command may also move newly added file or any other svn extension that i've missed, add carefully same in egrep -v option.
Move all unwanted files in a code base to a directory.
a) either one can use 'svn st' command and find all '?' files and manually copy and move them to other dir or
b) use power full linux utilities do it for you.
#svn st | egrep -v 'M|X|A|cscope|tags|Performing' | awk -F" " '{print $2}' | xargs -I {} mv {} not_needed/
i) 'svn st' list all files like modified, new etc.
In above command we carefully have to ignore display of modified files
'M' -modified
'A' - newly added
'cscope' - cscope tags
'tags' - ctags
'X' - unknow type and any other unwanted types like file name starting with 'Performing' etc
ii) awk -F" " '{print $2}' --- display filenames
iii) xargs -I {} mv {} not_needed/
[ {} is a placeholder meaning "the current argument". (You can use xxx or yyy or any other string instead of {} if you want, as well, and it'll do exactly the same thing.) -I implies -n1, because you want to act on each file individually. ]
Courtesy - http://www.linuxplanet.com/linuxplanet/tutorials/6522/3
You are done, the above command moves all unwanted files to folder name not_needed in above case.
Caution: Above command may also move newly added file or any other svn extension that i've missed, add carefully same in egrep -v option.
No comments:
Post a Comment