Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2006
    Location
    everywhere where u can find computer and internet
    Posts
    4

    Unanswered: Script (to do the same as find)

    Hello there. I have a task to make a unix shell script that does the same thing as find command. I should implement only -name -exec -print and -depth parameters.

    First step, is there a way to list all the files without using find comand?

    Can somebody help me with that?

    Tons'a'thanks

  2. #2
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool



    man ls



    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  3. #3
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool



    man ls



    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  4. #4
    Join Date
    Jan 2006
    Location
    everywhere where u can find computer and internet
    Posts
    4
    Yep...
    "ls -R"
    I figured that out, but wat to do with that list?

    Any comments?

    Thanks

  5. #5
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool


    Do the same thing as find command, depending on the option(s):

    For -name, you can use "grep"
    For -exec, just execute command replacing the {} with the dir/file name.
    For -print, echo the result.
    and for -depth, it's going to be a bit more difficult to simulate.

    Good luck!

    PS: You may want to use: ls -1R

    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  6. #6
    Join Date
    Jan 2006
    Location
    everywhere where u can find computer and internet
    Posts
    4
    I thought that grep would be the best choise to take out the things from the list, but how do I do that?

    e.g.

    .:
    file1
    file2
    file3

    ./dir1:
    file1
    file2
    file3

    ./dir2/dir3:
    file1
    file2
    file3

    if the output is like this, what pattern should I put to grep to take out the files i don't need, but still keep the dir's name, to locate the file?

    Millions of thanks...

  7. #7
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Smile


    man grep

    To exclude items do: grep -v {pattern}


    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •