Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Question How and What should I read/study to can resolve this script?


    Hello everyone,

    I am a newbie on the world Shell Script. I just can build some scripts basically with the command which I used on the terminal. With the part algorithmic I don't have problem, but some functionality I can't and didn't know how around the situation.

    I have the file .txt with more a less 800 000 lines with this structure:

    Code:
     . └── raiz  1 directory 
    . ├── [ 16K]  ./raiz │   
    ├── [ 12K]  ./raiz/tgdf │   │ 
      ├── [6.0K]  ./raiz/tgdf/a_fazer │   │
       ├── [7.5K]  ./raiz/tgdf/a_fazer_5 │   │
       ├── [7.9M]  ./raiz/tgdf/analise_.pdf │   │   
    ├── [241K]  ./raiz/tgdf/141.pdf │   │  
     ├── [ 18M]  ./raiz/tgdf/Aulas.pdf ....
    Which I need to do?
    1. Create an array with called "values";
    2. Read the file .txt and import the data on each line (all line) for to index the array called "values";
    3. The array called "values" will have another array, called "info_line";
    4. In the index, about array called "info_line", will be placed which was after last slash "/";
    5. The value this last array, "info_line", will receive which be between characters [...] - e.g. 6.0K;


    Basically I new create a multidimensionally array.
    The part which I don't know is "read the lines inside the file .txt" - collect exactly line by line. Collect the value which be after last slash "/".

    I appreciate the guidance about how and what I should read an study for I can do this functionality. I have been reading about regular express, I think this is very useful to do this kind of jobs, am I correct?

    I apologize about my level English, but if I can't explained the problem please tell me which I will try to explain the best I could. Thanks

  2. #2
    I am a retired db programmer and I can steer you in the proper direction.

    1) If I where to tackle this job I would use PHP to read a line at a time and process it useing explode, preg_match, strpos, etc to break the line into desired values.

    2) save the values in a sqlite db. Sqlite is built into php.


    If you don't know how to use php then all this can be done using regex in bash but it is harder to do.

    You could also use a combination of regex and bash to groom the text file, then import it into a spreadsheet such as excel or linux equivalent (LibreOffice), Google Docs for further processing.

  3. #3
    Quote Originally Posted by jwzumwalt View Post
    I am a retired db programmer and I can steer you in the proper direction.
    stay retired since you obviously dont have the skills or common sense needed to function. the threads your troweling up have been dead for year(s) and you cant even give decent advice in them.
    1) If I where to tackle this job I would use PHP to read a line at a time and process it useing explode, preg_match, strpos, etc to break the line into desired values.
    if you 'where' to tackle the job? and php to parse a file? never heard of perl/python/ruby that all have built in functions to parse data much faster and load things to database?
    2) save the values in a sqlite db. Sqlite is built into php.
    ...and is very slow and pointless since using mysql is the standard these days
    If you don't know how to use php then all this can be done using regex in bash but it is harder to do.
    so why dont you post some examples of your massive skills here so they poster can learn?
    You could also use a combination of regex and bash to groom the text file, then import it into a spreadsheet such as excel or linux equivalent (LibreOffice), Google Docs for further processing.
    seriously? you sure your retired or did you mean to say 'fired because I was incompetent"?

  4. $spacer_open
    $spacer_close
  5. #4
    iwzumwalt, habit's behaviour leaves much to be improved, but they're right:
    don't resurrect year-old threads.
    it's called necrobumping.
    sounds ugly, hmm?

    you don't need to artficially raise your post count here.
    How to ask smart questions | Don't be a Help Vampire
    You can post a link by removing "http://www." from it!

Posting Permissions

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