LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Show only executable files of a system folder (https://www.linuxquestions.org/questions/linux-newbie-8/show-only-executable-files-of-a-system-folder-627736/)

jianelisj 03-13-2008 06:29 AM

Show only executable files of a system folder
 
i would like some help the following problem:
show only executable files of a system folder.

My idea is: ls -h /.

but is does not work. Why?

I would appreciate any help.

onebuck 03-13-2008 06:52 AM

Hi,
Quote:

Originally Posted by jianelisj (Post 3087218)
i would like some help the following problem:
show only executable files of a system folder.

My idea is: ls -h /.

but is does not work. Why?

I would appreciate any help.

You should 'man ls' to get a better understanding of the command.
The 'ls -h /' says to list the content of the '/' and display in a human readable format. Your system probably displayed;
Code:

~#ls -h /
arc1/  bin/  etc/  lost+found/  opt/  sbin/  sys/  var/
arc2/  boot/  home/  media/      proc/  site/  tmp/
arc3/  dev/  lib/  mnt/        root/  srv/  usr/

Or something similar. If you want to display the content of '/' with a long listing then;

Code:

ls -lh
~#ls -lh /
total 88K
drwxr-xr-x  5 root root 4.0K 2008-03-08 21:16 arc1/
drwxr-xr-x  3 root root 4.0K 2007-08-04 11:15 arc2/
drwxr-xr-x  3 root root 4.0K 2007-08-04 11:20 arc3/
drwxr-xr-x  2 root root 4.0K 2007-04-29 23:35 bin/
drwxr-xr-x  3 root root 4.0K 2007-09-17 04:11 boot/
drwxr-xr-x 19 root root  14K 2007-12-01 09:59 dev/
drwxr-xr-x 61 root root 4.0K 2007-12-28 14:16 etc/
drwxr-xr-x  6 root root 4.0K 2007-12-13 18:21 home/
drwxr-xr-x  5 root root 4.0K 2007-08-04 11:42 lib/
drwx------  2 root root  16K 2007-08-04 11:01 lost+found/
drwxr-xr-x 16 root root 4.0K 2007-09-17 04:06 media/
drwxr-xr-x 16 root root 4.0K 2007-08-05 17:22 mnt/
drwxr-xr-x  2 root root 4.0K 2007-06-10 01:23 opt/
dr-xr-xr-x 94 root root    0 2007-11-06 04:31 proc/
drwx--x--- 10 root root 4.0K 2008-03-13 00:43 root/
drwxr-xr-x  2 root root 4.0K 2007-05-19 00:44 sbin/
drwxr-xr-x  2 root root 4.0K 2007-08-04 11:26 site/
drwxr-xr-x  2 root root 4.0K 2007-08-04 11:41 srv/
drwxr-xr-x 12 root root    0 2007-11-06 04:31 sys/
drwxrwxrwt  5 root root 4.0K 2008-03-12 17:46 tmp/
drwxr-xr-x 18 root root 4.0K 2007-02-21 12:31 usr/
drwxr-xr-x 17 root root 4.0K 2007-05-27 00:13 var/

If you want to see the content of a specific directory then;
Code:

~#ls -hl /boot
total 17M
lrwxrwxrwx 1 root root  37 2007-08-04 11:34 README.initrd -> /usr/doc/mkinitrd-1.1.2/README.initrd
lrwxrwxrwx 1 root root  32 2007-08-04 11:52 System.map -> System.map-huge-smp-2.6.21.5-smp
-rw-r--r-- 1 root root 778K 2007-06-19 15:18 System.map-generic-2.6.21.5
-rw-r--r-- 1 root root 795K 2007-06-19 14:53 System.map-generic-smp-2.6.21.5-smp
-rw-r--r-- 1 root root 1.2M 2007-06-19 15:23 System.map-huge-2.6.21.5
-rw-r--r-- 1 root root 1.2M 2007-06-19 14:58 System.map-huge-smp-2.6.21.5-smp
-rw-r--r-- 1 root root  512 2007-08-04 11:54 boot.0300
-rw-r--r-- 1 root root  512 2007-09-15 22:43 boot.0301
-rw-r--r-- 1 root root  512 2007-09-17 03:59 boot.0800
-rw-r--r-- 1 root root  168 2007-08-04 11:54 boot_message.txt
lrwxrwxrwx 1 root root  28 2007-08-04 11:52 config -> config-huge-smp-2.6.21.5-smp
-rw-r--r-- 1 root root  72K 2007-06-19 15:18 config-generic-2.6.21.5
-rw-r--r-- 1 root root  72K 2007-06-19 14:53 config-generic-smp-2.6.21.5-smp
-rw-r--r-- 1 root root  71K 2007-06-19 15:23 config-huge-2.6.21.5
-rw-r--r-- 1 root root  71K 2007-06-19 14:58 config-huge-smp-2.6.21.5-smp
-rw-r--r-- 1 root root 5.0K 2007-06-10 01:09 diag1.img
drwxr-xr-x 9 root root 4.0K 2007-09-17 04:01 initrd-tree/
-rw-r--r-- 1 root root 459K 2007-09-17 04:01 initrd.gz
-rw------- 1 root root 133K 2007-09-17 04:11 map
lrwxrwxrwx 1 root root  29 2007-08-04 11:52 vmlinuz -> vmlinuz-huge-smp-2.6.21.5-smp
-rw-r--r-- 1 root root 1.9M 2007-06-19 15:18 vmlinuz-generic-2.6.21.5
-rw-r--r-- 1 root root 2.0M 2007-06-19 14:53 vmlinuz-generic-smp-2.6.21.5-smp
-rw-r--r-- 1 root root 4.0M 2007-06-19 15:23 vmlinuz-huge-2.6.21.5
-rw-r--r-- 1 root root 4.3M 2007-06-19 14:58 vmlinuz-huge-smp-2.6.21.5-smp

You can wild card to get specific outputs within your list. You should 'man ls'.

'Learning the shell' is another good reference.

This link and others are available from 'Slackware-Links'

Tinkster 03-17-2008 12:24 PM

Quote:

Originally Posted by jianelisj (Post 3087218)
i would like some help the following problem:
show only executable files of a system folder.

My idea is: ls -h /.

but is does not work. Why?

I would appreciate any help.

What does the man-page say about -h? Does it
relate to executables?


Do your own homework.

iamwilliam 03-17-2008 12:37 PM

should go something like
Quote:

find . -perm /u=x,g=x,o=x
man find for more

sentient6 03-19-2008 09:29 AM

It's not that difficult if you try to do "man ls" and find for the option that matches your creteria...


edit: greek out :(

jianelis r e a d t h e m a n u a l

ashokJ 01-07-2012 03:18 AM

list only executables using ls Command
 
ls -F | grep '*'

or

ls -la | grep [w-]'x'[r-]

wirelessben 08-08-2013 08:47 AM

Linux Friendliness Score: 0
 
iamwilliam nailed it. His solution is not in the man page or the info pages, but it is here. This is the reason for this forum's existence: better documentation than the man pages.

onebuck didn't answer the question. Tinkster and sentient6 went further and admonished this new user for merely being inexperienced. Apparently they read every man page available (even though they can be horrible pieces of user documentation*) before ever asking a question, and thus feel entitled to pass judgment.

This may be feeding the trolls, but I couldn't let this post go unchallenged, as if this general attitude towards newbies is the standard. Per xkcd, "someone is wrong on the internet". :)

*Try "man history" if you doubt this.

szboardstretcher 08-08-2013 09:26 AM

You just revived a necro thread that had its last comment a year and a half ago, giving a proposed solution to a question 5 years ago.


All times are GMT -5. The time now is 10:29 PM.