listing files and piping

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions listing files and piping
# 1  
Old 03-02-2011
listing files and piping

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:

list is long form all those files in your home directory that have read write and execute permissions for you, and whose name contains the string "txt"

2. Relevant commands, code, scripts, algorithms:
ls
find


3. The attempts at a solution (include all code and scripts):
ls -l would tell me the permissions
but find . -type perm 777 would give me files that have read write execute permissions
However , i feel like i should pipe it because i need a long form of those files


4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
Toronto, Ryerson , Woit, cps393

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
# 2  
Old 03-02-2011
There should be nothing wrong with a pipe, but you would need xargs to make ls read from stdin - though here is an example how to do it without a pipe:

Code:
find . -perm 777 -name "*txt*" -exec ls -l {} \;

I am not sure if 777 is the right way, since your user would be able to rwx it, no matter if he is owner or in the group, as all (others) can rwx it. Since it is your home directory being mentioned you should be the user that has rwx on it. So to be more exact, you might take
Code:
find . -perm u=rwx -name "*txt*" -exec ls -l {} \;

as this just defines permissions for the user/owner of the file(s).

And if it is really only files you should list, ie. no directories, I would suggest:
Code:
find . -type f -perm u=rwx -name "*txt*" -exec ls -l {} \;

# 3  
Old 03-03-2011
hi thank you for the help, would this work out the same too
ls -l | find . -name "*txt*" - perm 700

---------- Post updated at 11:25 PM ---------- Previous update was at 07:43 PM ----------

forget the above, it says list in short form ( just the file names) , so the command
find . -perm 777 -name "*txt*"
would allow me to list in short form ( namely just the file names) ?
# 4  
Old 03-05-2011
This should find all files which match the criteria:

Code:
find . -type f -name '*.txt' \( -perm -0700 -o -perm -0070 -o -perm -0007 \) -exec ls -ald {} \;

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Listing the file name and no of records in each files for the files created on a specific day

Hi, I want to display the file names and the record count for the files in the 2nd column for the files created today. i have written the below command which is listing the file names. but while piping the above command to the wc -l command its not working for me. ls -l... (5 Replies)
Discussion started by: Showdown
5 Replies

2. Shell Programming and Scripting

piping from grep to awk without intermediate files

I am trying to extract the file names alone, for example "TVLI_STATS_NRT_XLSTWS03_20120215_132629.csv", from below output which was given by the grep. sam:/data/log: grep "C10_Subscribe.000|subscribe|newfile|" PDEWG511_TVLI_JOB_STATS.ksh.201202* Output: ... (6 Replies)
Discussion started by: siteregsam
6 Replies

3. UNIX for Dummies Questions & Answers

Need help with listing files

Hi, I came up with this question in one of the exercises . Use find to produce a long ls listing of all files in /usr/bin that are more than 750Kb long. You’ll need to use a form like find ..... -exec ls -l {} \; The semicolon must be escaped, but not the . I tried using below code ,... (1 Reply)
Discussion started by: krthknaidu
1 Replies

4. Shell Programming and Scripting

Problem in piping the file(s) content from zip files

Hi friends I have a zip file 1.zip which contains three text files a.txt b.txt c.txt I want to grep some text(keyword) in those 3 files without extracting all the three files to a local directoryusing the command, unzip -p 1.zip |grep "search text" >result.txt The Output file is... (2 Replies)
Discussion started by: ks_reddy
2 Replies

5. Shell Programming and Scripting

perl script for listing files and mailing the all files

Hi, I am new to perl: I need to write perl script to list all the files present in directory and mail should be come to my inbox with all the files present in that directory. advanced thanks for valuable inputs. Thanks Prakash GR (1 Reply)
Discussion started by: prakash.gr
1 Replies

6. UNIX for Dummies Questions & Answers

Sorting with unique piping for a lot of files

Hi power user, if I have this file: file1.txt: 1111 1111 2222 2222 3333 3333 3333 4444 4444 4444 when I run the sort file1.txt | uniq > data1.txt the result is (2 Replies)
Discussion started by: anjas
2 Replies

7. UNIX for Advanced & Expert Users

listing files excluding files from control file

I have a directory named Project.I have a control file which contains valid list of files.I would like list the files from directory Project which contains files other than listed in the control file. Sample control file: TEST SEND SFFFILE CONTL The directory contains followign... (15 Replies)
Discussion started by: ukatru
15 Replies

8. Programming

Listing Files

Dear All, I want to list all the files of a Directory. I am not able to find out the code. So plz send me code in C in Unix Environmrnt so that I can Display all the file names of a Directory (3 Replies)
Discussion started by: krishna_sicsr
3 Replies

9. Filesystems, Disks and Memory

help - listing files

Hi, is there a way from the command line that I can list all files whose names are say 20 characters or more and direct the results into a file. I'm using RH9. thankx (2 Replies)
Discussion started by: richarmj
2 Replies

10. UNIX for Dummies Questions & Answers

Recursive directory listing without listing files

Does any one know how to get a recursive directory listing in long format (showing owner, group, permission etc) without listing the files contained in the directories. The following command also shows the files but I only want to see the directories. ls -lrtR * (4 Replies)
Discussion started by: psingh
4 Replies
Login or Register to Ask a Question