Need help with a few commands

Discussion in 'Command Line' started by kayden, Dec 10, 2013.

  1. kayden

    kayden New Member

    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    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!!
  2. arochester

    arochester Super Moderator Staff Member

    Messages:
    909
    Likes Received:
    300
    Trophy Points:
    63
    Homework assignment?
  3. kayden

    kayden New Member

    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    yeah It's actually for finals review
  4. ryanc

    ryanc New Member

    Messages:
    12
    Likes Received:
    7
    Trophy Points:
    3
    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.)
    DevynCJohnson likes this.
  5. Kovax

    Kovax Member

    Messages:
    34
    Likes Received:
    19
    Trophy Points:
    8
    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
  6. B4RTZ4K

    B4RTZ4K New Member

    Messages:
    19
    Likes Received:
    13
    Trophy Points:
    3
    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
  7. byau

    byau New Member

    Messages:
    4
    Likes Received:
    3
    Trophy Points:
    1
    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.
    DevynCJohnson likes this.
  8. MikeyD

    MikeyD Active Member

    Messages:
    232
    Likes Received:
    113
    Trophy Points:
    43
    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: Mar 3, 2014
  9. GrumpyOldMan

    GrumpyOldMan Active Member

    Messages:
    158
    Likes Received:
    50
    Trophy Points:
    28
    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.
  10. MikeyD

    MikeyD Active Member

    Messages:
    232
    Likes Received:
    113
    Trophy Points:
    43
    That makes sense. Thinking procedurally though it angered me to be given such ambiguous instructions :confused:

Share This Page