Filer out binaries
Hi All,
This is probably the easiest question every. But here goes... If the I have a directory the contains .c .o and binaries how do I filter out the .c .o files so that I can see only the binaries (they have on extension) I can do: Code:
ls *.c I also need to copy just the binaries to a different directory. How can I do this using the cp command? The DOS commands would be: Code:
dir *.exe Pete |
Same goes for Linux:
cp *.c /new/dir |
Yes but the binaries don't have an extension.
eg. file.c file.o file (no extension) |
Should I conclude that this can't be done?
|
Code:
for file in * Code:
for file in * This requires the executables to be executable by the user the script runs as, since that's what the -x bash test relies on. Håkan |
Rather than trying to mess with the names, and going on the principle that they're executable and nothing else but directories are, this might work. No guarantees, but I tested it briefly and it seemed okay. Though once a couple of my files disappeared - think it was just a typo when I changed the destination. :D
Code:
for f in `ls .`; do if [ -x $f -a \! -d $f ]; then mv $f /target_dir/; fi; done |
I beat ya to it but you beat me on the directories. :)
I really should have thought of that. Håkan |
Yeah - I'm just relieved to see a similar approach. :) Seems like there ought to be a more direct way.
|
Ok. Thanks for your help.
I think I will just copy all the files and delete the .c and .o files using rm *.c Thanks Peter |
All times are GMT -5. The time now is 10:42 AM. |