Help with sorting executable files in shell


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Help with sorting executable files in shell
# 1  
Old 12-30-2011
Java Help with sorting executable files in shell

Hi!I'm new in this forum,also in shell scripting! :P
I'd like to help me with an issue!the project wants to make a variable with a directory(any) and then print all executable files of this directory,sorted by size!Thank you!
# 2  
Old 12-30-2011
seems like a homework

post this in homework section
# 3  
Old 12-30-2011
Nope!just practicing!i found random exercises and i'm trying to practice on shell scripting!(sorry for my terrible english! )
# 4  
Old 12-30-2011
what you tried so far ?
# 5  
Old 12-30-2011
my problem is passing a directory into a variable...i've thought this : dir_name=$(dirname $0)
now to print the executable files sorted by size i wrote this:
echo "executable files by size order:"
find $dir_name -type -f -perm -og+x | sort -nr
# 6  
Old 12-30-2011
First let's get the "find" right: We're looking for any executable file so we need to check User, Group and Other permissions for the Executable bit. Within the protected brackets of this command the two standalone "-o" switches mean "OR".

Code:
find "${dir_name}" -type f \( -perm -u+x -o -perm -g+x -o -perm -o+x \)

Now ... the output from "find" will be a straight list of filenames which does not mention the size of the file.
This User Gave Thanks to methyl For This Post:
# 7  
Old 12-30-2011
ok!thanks for this by the way!now with this i can have a list with the executable file in directory dir_name...
i can sort them now with this command?
find "${dir_name}" -type f \( -perm -u+x -o -perm -g+x -o -perm -o+x \) | sort -nr
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

cygwin executable shell scripts

Hello, Cygwin will execute a shell script without turning on executable status on the file. I want to force cygwin to be more like linux and not execute scripts directly on the command line unless changing mode to have executable status. Is this possible? Thanks Larry (2 Replies)
Discussion started by: larrye0123
2 Replies

2. UNIX Desktop Questions & Answers

creating an executable file from shell scripts

Hi Friends, I have a shell script which does some operations etc, would it be possible to create an executable file out from this shell script? meaning the executable file is not editable, thus the source code will not be visible to other users for copyright reasons. Please help, thanks! (1 Reply)
Discussion started by: kokoro
1 Replies

3. Shell Programming and Scripting

[SHELL] Executable? Run it!

I would like to make a script that I can see if the file is executable. If it is executable then it needs to run. Otherwise, if it is not executable the file needs to be edited, and run agian. I hope you understand what i mean. :) Thanks for the netherlands (4 Replies)
Discussion started by: dennisbest85
4 Replies

4. Homework & Coursework Questions

File Looping - Looking for executable files - Need help

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! Hello all, I have posted here before and really was blown away by the amount of assistance I received. I was able to finish my homework without a problem! But, yet again, our... (6 Replies)
Discussion started by: Bob07
6 Replies

5. Shell Programming and Scripting

convert shell script into a binary executable

Hello every one, i want to convert my shell script into a binary executable a .exe file , is it possible to do that if so are there any tools . Would the script take off when the arguments are parsed. Thanks Venu (13 Replies)
Discussion started by: venu
13 Replies

6. Shell Programming and Scripting

Exit shell after setting executable to run?

Hi, I have an executable file that has a rather long and tedious process to complete. How would I launch the executable using the shell, and then exit the shell while leaving the executable to run in the background? (1 Reply)
Discussion started by: pcwiz
1 Replies

7. UNIX for Dummies Questions & Answers

executable files

hello. My question, basically is: what is the definition of unix/linux exec files, or what makes a file executable? More specifically, must a unix source file that was compiled using gcc have exec permissions in order to be considered executable? Is it right to say that a unix/linux exec file... (1 Reply)
Discussion started by: nadavkri
1 Replies

8. Shell Programming and Scripting

Need to call an Executable (.exe) using shell

Hi all , I need to call an executable (.exe) using shell script. Actual need is i need to call that shell script and do an export of some tables is there any way . the executable is datamover Please let me know if there are any option !! (2 Replies)
Discussion started by: raghav1982
2 Replies

9. UNIX for Dummies Questions & Answers

Executable files

This question always confuses me :- Suppose I write a program and compile it on a machine with operating system A and processor B will the exe file run on a machine with operating system A2 but processor B operating system A but processor B2 operating system A2 and processor B2........ ... (9 Replies)
Discussion started by: nervous
9 Replies
Login or Register to Ask a Question