Finding the executable files of a directory using Grep


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Finding the executable files of a directory using Grep
# 1  
Old 05-02-2011
Finding the executable files of a directory using Grep

Hi guys,
Can you please help me print all the executable files of a directory(in this case /home) using grep?
All i know is that this command should do it but it doesnt...

Code:
ls -l ~ | grep -..x

it shows me the following mesage

Code:
grep: invalid option -- '.'
Χρήση: grep [ΕΠΙΛΟΓΗ]... ΥΠΟΔΕΙΓΜΑ [ΑΡΧΕΙΟ]...

# 2  
Old 05-02-2011
Code:
ls -l | grep  '\-..x'

This User Gave Thanks to Franklin52 For This Post:
# 3  
Old 05-02-2011
Code:
ls -l ~ | grep -- -..x

Code:
ls -l | sed -n '/^-..x/p'

This User Gave Thanks to ygemici For This Post:
# 4  
Old 05-02-2011
Thanks guys for the help
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Linux

Finding files older than x days within directory with spaces

Hi, I am trying to run a command that finds all files over x amount of days, issue is one of the directories has spaces within it. find /files/target directory/*/* -type f -mtime +60 When running the above the usual error message is thrown back + find '/files/target\' 'directory/*/*' -type... (1 Reply)
Discussion started by: Ads89
1 Replies

2. Shell Programming and Scripting

Finding files in directory with similar names

So, I have a directory tree that has many files named thusly: X_REVY.PDF I need to find any files that have the same X portion (which can be nearly anything) as any another file (in any directory) but have different Y portions (which can be any number from 1-99). I then need it to return... (3 Replies)
Discussion started by: Kamezero
3 Replies

3. UNIX for Dummies Questions & Answers

Finding the same pattern in three consecutive lines in several files in a directory

I know how to search for a pattern/regular expression in many files that I have in a directory. For example, by doing this: grep -Ril "News/U.S." . I can find which files contain the pattern "News/U.S." in a directory. I am unable to accomplish about how to extend this code so that it can... (1 Reply)
Discussion started by: shoaibjameel123
1 Replies

4. UNIX for Dummies Questions & Answers

finding keywords in many files using grep

Hi to all Sorry for the confusion because I did not explain the task clearly. There are many .hhr files in a folder There are so many lines in these .hhr files but I want only the following 2 lines to be transferred to the output file. The keyword No 1 and all the words in the next line They... (5 Replies)
Discussion started by: raghulrajan
5 Replies

5. Shell Programming and Scripting

Finding files in directory

Hi, I need help in writing shell script to accomplish the following. 1.I've one text file which contains list of batch numbers like b1.dat,b2.dat,b3.dat... 2.I've the same files along with other files present in some directory.i.e 1.dat,2.dat,3.dat,4.dat,5.dat... present in some directory.... (3 Replies)
Discussion started by: narranil2
3 Replies

6. Shell Programming and Scripting

finding the 5 newest files in a directory

I have a folder that has new files created everyday, is there a way i can filter them so that only the 5 newest files are displayed? I'm hoping this can be done by a one liner without a script. for example my directory contains -rw-r--r-- 1 root root 0 Jun 24 08:34 file112 -rw-r--r-- 1 root... (2 Replies)
Discussion started by: zerofire123
2 Replies

7. Shell Programming and Scripting

Finding all the files in a directory

I need to find all the files with a given file name present in the sub directories and execute a script on each file For example In the directory source , I need to find all the files named test and execute the script run.sh Can anyone please help me on this (4 Replies)
Discussion started by: prav076
4 Replies

8. Shell Programming and Scripting

Finding files in current directory when 100,000's files in current directory

Hi All I was wondering what is the most efficient way to find files in the current directory(that may contain 100,000's files), that meets a certain specified file type and of a certain age. I have experimented with the find command in unix but it also searches all sub directories. I have... (2 Replies)
Discussion started by: kewong007
2 Replies

9. Shell Programming and Scripting

finding 0 byte files in current directory only

Hi Gurus, I have a directory A, which has some 0 byte files in it. This directory also has a subdirectory B which also has some 0 byte files in it. The problem: I only need to find out the names of the 0 byte files in the directory A. I'm using the following command find . -name *.zip... (6 Replies)
Discussion started by: ramky79
6 Replies

10. UNIX for Dummies Questions & Answers

Finding executable files in all directories

This is probably very easy but I would like to know a way to list all my files in all my directories that are readable and executable to everyone. I was told to use find or ls and I tried some stuff but couldnt get it to work. I understand that its dangerous to have files with these permissions for... (4 Replies)
Discussion started by: CSGUY
4 Replies
Login or Register to Ask a Question