Find the answer to your Linux question:
Results 1 to 8 of 8
Using a bash scipt How would you get the number of files in a directory. Then run a for loop for each of the files in the directory, such that ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2005
    Location
    South Africa
    Posts
    88

    Bash question


    Using a bash scipt
    How would you get the number of files in a directory.
    Then run a for loop for each of the files in the directory, such that you can operate on the file?

  2. #2
    Linux User
    Join Date
    Jul 2004
    Location
    Poland
    Posts
    368
    There's a small subtlety in this question. Do you want files from subdirectories included or not?
    "I don't know what I'm running from
    And I don't know where I'm running to
    There's something deep and strange inside of me I see"

  3. #3
    Linux User eugrus's Avatar
    Join Date
    Dec 2004
    Location
    Russia
    Posts
    391
    Russian UNIX Forums
    http://eugrus.pp.ru

  4. #4
    Just Joined!
    Join Date
    Mar 2005
    Location
    South Africa
    Posts
    88
    Thanks, That's pretty much what i was trying to do.

  5. #5
    Linux Guru techieMoe's Avatar
    Join Date
    Aug 2004
    Location
    Texas
    Posts
    9,496
    The Forum Rules clearly state that we will not do your homework for you, and this thread looks suspiciously like a homework question.

    Quote Originally Posted by Forum Rules
    Dont give us YOUR homework questions - Dont be so bloody lazy. If you post your homework for someone else todo, dont be supprised or get upset if your post is removed. Asking for a brief pointer on a *particular area* IS ok. Verbatim Copying of multiple assignment questions and attaching a note at the bottom saying "please help me" is not. We were all at school/college/uni once upon a time, and we know what homework questions look like
    eugrus, I understand that you were trying to be helpful, but posting a program already written for this person is not a precedent that should be set in these forums. If indeed the original poster has asked a homework question, you've effectively helped this person cheat, and therefore not actually learn anything.
    Registered Linux user #270181
    TechieMoe's Tech Rants

  6. #6
    Linux User eugrus's Avatar
    Join Date
    Dec 2004
    Location
    Russia
    Posts
    391
    techieMoe
    posting a program already written
    it is the way to make one understand the technology
    not more

    homework questions
    I do not think it is so.
    This is just a thing people really often need, while writing scripts.
    Russian UNIX Forums
    http://eugrus.pp.ru

  7. #7
    Linux Guru techieMoe's Avatar
    Join Date
    Aug 2004
    Location
    Texas
    Posts
    9,496
    I'll leave this to a moderator. As far as I'm concerned this entire post is against the forum rules and should be taken off.
    Registered Linux user #270181
    TechieMoe's Tech Rants

  8. #8
    Linux Guru
    Join Date
    Apr 2003
    Location
    London, UK
    Posts
    3,284
    topic locked as the original question has been answered and i don't forsee the conversation going anywhere constructive

Posting Permissions

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