loop through a DIR to delete files by inode
I have a directory that contains some files (over a 1,000) that have a '\' in the filename. There are also some good files that I need to keep. therefore I need a script to delete based on inode.
What I have thus far: list="$(ls -il /opt/PC/log/*RPOUT*.xml)" #this gives me the list # I need to get the inode of. for i in $list do find . -inum $i -exec rm -i {} \; echo "delete file" $i >> /home/me/tmp/del_inode.txt done echo 'completed' I know this is not right ... what I know is is the 'find' is. I need to loop through the $list gleaning inodes to get all the files with '\' delete. I'm not sure how. The $i gives me the whole line. I just want the first position. set $() does not seem to work ... any ideas? |
That approach seems overly complicated to me. Have a look at this:
Code:
$ touch foo 'ba\r' baz 'b\o\o' |
I'll be ... loop was way too complicated
Thanks anomie.
I was way over thinking this. That worked like a champ. Thank you!!! ;) you get a gold star for the day ... |
rm: Argument list too long
what about:
-bash: /bin/rm: Argument list too long is there a solution for that? It appears to be a limitation for rm as there is a very large list of files. |
Perhaps this will work.
Code:
find . -name "*\\\*" -delete |
rm - Argument list too long
You guys are just awesome with solutions. There was 12137 files and rm puked but find worked fine.
Thanks!!! |
All times are GMT -5. The time now is 03:01 PM. |