#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    2
    Rep Power
    0

    Some homework help


    What are the commands for these I have tried a lot of different ways like echo but its not showing anything


    Wildcards in the Bash shell

    Apply the following commands in the /usr/bin directory on munro.
    Record the command used in each case. Record the number of files matched. by piping the result through the wc command. (I am not looking for an actual list of files)

    eg (for all files): ls | wc -l

    a) list the name of all the files in the /usr/bin directory that start with ls.
    b) list the name of all the files in the /usr/bin directry that end with ls
    c) list the name of all the files that start with the letter q and end with the number 3
    d) list the name of all the files that consist of 2 letters where the 1st letter is in the range from d to p.
    e) List the name of all the files that start and end with a vowel.
    f) List the name of all the files that start and end with a vowel where the whole file name is only 4 characters long.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,451
    Rep Power
    1751
    Not that we would not have guessed, but thank you for admitting it is homework!

    I am guessing you'll need to run a lot the commands twice - once to get the output and once to obtain the count, such as the first one - listing the names of the files matched is not always conducive to returning a count!

    Wildcards are, I am sure you are aware, either ? for a single character or * for 0 or more characters; thus A?C will match ABC and AXC but not ABBC. A*C will match AC, ABC, ABBC. beyond wildcards you can also use regular expressions to perform filtering and some of the questions lean towards using those.

    a) to list all files in /usr/bin that start with ls, you will need:
    Code:
    ls /usr/bin/ls*
    b) to list those files ending with ls you will need:
    Code:
    ls /usr/bin/*ls
    c) to list things starting with q and ending in 3:
    Code:
    ls q*3
    Wildcards are quite simple, so I have not bothered getting you to study them. Regular expressions are something you really should be more aware of, so I suggest you look them up and 'have a play' with to get a better understanding of them.
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc
  4. #3
  5. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,673
    Rep Power
    1958
    @SafetyMoose
    It is great you admit that it is help to homework, just take notice that the title should be a short description of the error, e.g. "Need help with bash shell command".
    If you look at front of the title screen, you will find a list of categories wherefrom you can select "homework".

    I suggest you also take a look at the README threads as they contain valuable information.

    Originally Posted by SimonJM
    Not that we would not have guessed, but thank you for admitting it is homework!
    Personally, I am more open minded to see what kind of help I can give if they admit at start it is about homework.
    But I guess we all had our shares of "need help" posts with a very nice copy/paste of the entire task the user were given.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    2
    Rep Power
    0
    Hey guys! I am curious on how you got those commands. Thanks again!
  8. #5
  9. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,673
    Rep Power
    1958
    Not sure if this is what you asked for, but you can look up the man page for ls to get the command parameter.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,451
    Rep Power
    1751
    Originally Posted by SafetyMoose
    Hey guys! I am curious on how you got those commands. Thanks again!
    Reading, studying, courses
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc
  12. #7
  13. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2006
    Posts
    857
    Rep Power
    388

    Cool


    Originally Posted by SafetyMoose
    Hey guys! I am curious on how you got those commands. Thanks again!
    Click here for summary of Unix commands.

IMN logo majestic logo threadwatch logo seochat tools logo