Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Kalixa

macrumors member
Original poster
Jun 25, 2007
73
0
Hello. I have a lot of binary linux files which I compiled back in the time I used linux. They are organized into several subfolders which have both the source code, a backup of the source code and the binary file. Can someone please help me to find out how to move/or delete these files, without having to drag and drop each individual file. (That would take quite a long time).
 

toddburch

macrumors 6502a
Dec 4, 2006
748
0
Katy, Texas
Got a naming convention? Is there a tree structure that can be followed by a script? Got a list of all the files or paths you want if they are spread across tarnation?

Not enough information to propose a solution.

Todd
 

mkrishnan

Moderator emeritus
Jan 9, 2004
29,776
15
Grand Rapids, MI, USA
Yeah, I don't understand based on the information either. You can create a zip or tar file and then add files to it by directory. Or else, if you're at least mildly organized, you can just copy the entire uplevel folder onto your backup device. But since you're asking the question, I'm guessing that's not an option for some reason, but I don't know why?
 

ChrisA

macrumors G5
Jan 5, 2006
12,912
2,158
Redondo Beach, California
Can someone please help me to find out how to move/or delete these files, without having to drag and drop each individual file. (That would take quite a long time).

If there is a pattern to the names you can use "find". See "man find". It will apply a command to a set of files that match a pattern. The pattern is very general and can be things like "executable files with date before X and with "s" as the third letter in the name and all are under directory Y. Find can be very usfull when you have many, many files that all need the same thing done to them.
 

Mumford

macrumors regular
Oct 8, 2006
181
3
Altadena, CA
If you're not afraid of using the terminal, this is easy. The 'file' command will give you info about a file. For a linux binary I just copied to my Mac as a test it reports:

Code:
bash: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV),
for GNU/Linux 2.2.5, dynamically linked (uses shared libs), stripped

So theoretically all you need to do is run 'file' on every file in that tree, grep for linux in the results and rm them. You can use the command below for that. Replace the '.' at the start with the start of the directory tree that has all these files:

Code:
$ rm `find . -type f -exec file '{}' \; | grep -i linux | awk -F: '{print $1}'`

If that's too scary, just run this:

Code:
$ find . -type f -exec file '{}' \; | grep -i linux | awk -F: '{print $1}'

to see what linux files it finds without actually removing them.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.