Need help with a few commands

K

kayden

Guest
Hello everybody, I just had a few questions about the "find" command, and was wondering if anyone could provide some assistance. Any help will be very much appreciated.

I just need to know what commands I would type for the following:

1.a find command that will find all files in the current directory that begin with the letter A

2.Without changing directories, write a find command that will find all files in the /etc directory that begin with br and end with .d

3.Find all files in the current directory that are symbolic links

4. Find all files in the current directory that are more than 10K bytes in size.


5. Find all files in the current directory that end with .pl and were modified more than 30 days ago

6. Use the touch command to set the modification date of some of the files in the current directory and/or its subdirectories to the current day and time. Then find all files in the current directory that are less than 8K bytes in size and were modified less than 30 days ago

Thank you very much for your help!!
 


I would suggest you start by looking at the man pages for the commands find and touch. Some of those questions can easily be answered with the ls command and globbing too.

(Not going to give you the answer directly seeing as you've admitted it's homework.)
 
I would suggest to take a look at the MAN pages for find. There you would/should find some examples for running the command and getting what you are looking for.

Kovax
 
Look for wildcards. I say no more loool:rolleyes:
Or if u had this already done could u give me the answers plz.

Regards B4rtz4k
 
Thanks for admitting it's homework. You definitely will "find" everything in the find man page (pun intended). Man pages on linux are very handy since there are useful examples too.
 
I think it has been plenty of time (Original post was on Dec. 10th). Should be safe to post answers if anyone wants to take a swing at it. Here is my guess (without being able to test these commands, freaking Windows work PCs :confused:):

1.a find command that will find all files in the current directory that begin with the letter A
Code:
find . -maxdepth 1 -name "[Aa]*"

2.Without changing directories, write a find command that will find all files in the /etc directory that begin with br and end with .d
Code:
find /etc -name "br*.d"

3.Find all files in the current directory that are symbolic links
Code:
find . -maxdepth 1 -lname "*"
I think "-type" could also be used (and is probably more straightforward)

4. Find all files in the current directory that are more than 10K bytes in size.
Code:
find . -maxdepth 1 -size +10k

5. Find all files in the current directory that end with .pl and were modified more than 30 days ago
Code:
find . -maxdepth 1 -name "*.pl" -mtime "+30"

6. Use the touch command to set the modification date of some of the files in the current directory and/or its subdirectories to the current day and time. Then find all files in the current directory that are less than 8K bytes in size and were modified less than 30 days ago
?? Not sure if this question is just dumb or dumbly worded. I'm supposed to touch some files and then issue a completely different find command? I'll touch all the files I find...
Code:
find . -maxdepth 1 -size "-8k" -mtime "-30" -exec touch '{}' \;
 
Last edited:
I think the goal of that last question was to make sure that there were some [known] files to find. After all, it was classwork.
 
That makes sense. Thinking procedurally though it angered me to be given such ambiguous instructions :confused:
 
Find all files in the current directory that end with .pl and were modified more than 30 days ago
 

Members online


Latest posts

Top