Script required to delete a list of files?Forum: Extension Development Topic: Script required to delete a list of files? started by: Juanito Posted by Juanito on April 13 2008,05:56
In order to upgrade the versions of bison, pkg-config, expat, etc in compile-3.3.5, it would make life a lot easier if I had a script to delete a list of files. This would avoid starting again from the beginning and would avoid the hit or miss approach of hoping the new version of an app would completely overwrite the old version of an app.If a list of files is produced by:
- then I was thinking I could replace "/opt/test/" with "/opt/compile-3.3.5/" in "files" and then call a script that would delete all the files in "files" I would guess this would only require a couple of lines, but it is beyond my (almost non-existant) scripting ability... Posted by ^thehatsrule^ on April 13 2008,06:03
Why not uninstall them?If you still have the source tree that has the same configure options, you can run `make uninstall` Posted by Juanito on April 13 2008,09:30
Ah, thanks - this did the trick:
Posted by ^thehatsrule^ on April 13 2008,17:15
Well, if you're just reconfiguring it, you don't need to build it - just do make uninstall right after. Posted by roberts on April 13 2008,17:32
Just to answer the original question, I find myself typing loops on the command line to process lists. Example:# for F in `cat myfiles.lst`; do echo "$F"; done This just echos back your list to insure that the loop is typed correctly. I always start with a simple echo; just to be sure. Sometimes I am paranoid and will then replace the echo with ls -1 to be sure that files that I think I am going to be processing are really there. Then when I calm down I replace the command (echo or ls -1) with the actual command I wish to perform, usually sed -i, tr,awk, or rm I know many times one could use find together with -exec, but that is not always available, so too, one could use find with xargs but I still uses loops on the command line. Posted by Juanito on April 22 2008,08:38
Thanks:
On a connected topic:
Posted by mikshaw on April 22 2008,12:54
The leading / is removed when the package is created.Probably the easiest thing to do is "cd /" before removing files. Posted by ^thehatsrule^ on April 22 2008,17:25
fyi, those code snippets would only work on filenames not containing whitespace.You could set IFS to newline or use `while read LINE; do echo $LINE; done < filelist ` (which can be more resource friendly afaik) Posted by mikshaw on April 22 2008,17:39
also, an alternative to cd:while read LINE; do echo "/$LINE"; done < filelist |