Question about simple script?

Discussion in 'General Linux' started by UserMane, Apr 20, 2014.

  1. UserMane

    UserMane New Member

    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Hello,

    I would like to write a small program/script and am looking for advice on how to do so. I do not have a preference about which method or language to use, hopefully looking for the simplest way to do this.

    I have a program that runs on text files e.g. "program file1.txt file2.txt"

    I have 20 folders that each have 5-10 text files. I want to automatically get the name of the largest size text file from each of the 20 folders, and then run the program on these 20 files as described above.

    Ideally I could point my script to a folder, and it will automatically find the largest .txt file in each of the subdirectories and run "program file1.txt file2.txt file3.txt ..."

    Any ideas on how to most efficiently accomplish this? Ideas or links to tutorials if applicable are helpful.


    Thank you
  2. ZZs

    ZZs Active Member

    Messages:
    136
    Likes Received:
    50
    Trophy Points:
    28
    What does ur teacher prefer ?
  3. UserMane

    UserMane New Member

    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    This isn't for school. What I am doing now is File -> Open and selecting one file from each folder about 25 times when I run the program, and I thought this seems like something that could be automated relatively easily.

    It has been a while since I have done any programming and I am thinking about getting back into it. This could be a script using bash, python, or a program in C++ that would run in dos/windows.

    I am looking for potential ideas or tips as to which commands to use. I understand 'search or read the tutorials' is appropriate but a point in the right direction would be helpful.
  4. ZZs

    ZZs Active Member

    Messages:
    136
    Likes Received:
    50
    Trophy Points:
    28
    its simple, just how you use the "du" command.
  5. NsAneSmilez420

    NsAneSmilez420 New Member

    Messages:
    4
    Likes Received:
    2
    Trophy Points:
    1
    If I have understood your question correctly, then you might want to check out this link to a post, on stack overflow.
    Hope it helps....

    OK since im a new member i cannot post links yet, so if you google "bash commad to retrieve largest file from folder"

    it should be the first link
    bashcommando likes this.

Share This Page