Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6617371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:41:47+00:00 2026-05-25T20:41:47+00:00

I wrote a script to print specific days of a log file ! the

  • 0

I wrote a script to print specific days of a log file ! the script work properly , but I wrote the loop part with while read line and the log file contains more than 150000 items ! the script wants to read it line by line and it takes hours !so, the while should be changed in some way ! I know about for I in {1..N} but I want something better that work for any log file .

what do you suggest ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:41:48+00:00Added an answer on May 25, 2026 at 8:41 pm

    You’ll have to show us what you are doing. Please edit your posting to include smallest subset of while loop code that illustrates your problem. Also please show exact text of any errors or warning msgs.

    Per your comment ‘… I should press enter for each line to be read’. You are definitely doing something wrong. Reading each line should be automatic. Here is a basic outline of processing files with bash.

    Would you consider using awk? I can post better solutions with that standard tool.

     inputFiles="${@}"
     cat "${inputFiles}"\
     | while read line ; do
         case ${line} in
            2[0-9][0-9][0-9]-[0-1][0-9]-[0-3][0-9]* ) 
                # matched date
                 print ${line}
            ;;
            * )
                # you'll need to add other reg-expes here to extract data you want
            ;;
          esac
     done
    

    You may have to remove the dbl-quotes on ${inputFiles}.

    The purpose of using cat ${inputfiles | while read line ... is to allow processing any files you list on the cmdline.

    Have you tried using grep to look thru your logfiles?

     date1='2011-09-11' ; date2='2011-09-12'; date3='2011-09-13'
     grep "${date1}|${date2}|${date3}" *.logFiles | grep -i error
    

    You could also use the date1… as a case target in the while loop above.

     case ${line} in
       ${date1}*|${date2}*|${date3}* )
          echo $line
       ;;
     esac
    

    You may get away with removing the ‘*‘s above OR if the date is NOT the first element in the line, you may need to add ‘*‘ in front of each ${dateN}.

    Or if you’re keeping your logfiles zipped up,

     gunzip -c ${zippedLogFiles_gz) | grep "${date1}|${date2}|${date3}" | grep -i error
    

    is often a good place to start (and only unzips your files in place (just sending the uncompressed output into the pipe)).

    P.S. as you appear to be a new user, if you get an answer that helps you please remember to mark it as accepted, and/or give it a + (or -) as a useful answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote this script which counts occurrences of particular pattern in a given file.
i have wrote a script to produce an array of data but now want
I wrote a perl script a while ago which logged into my online banking
I wrote the following Perl script (below) in order to create simple XML file.
I wrote a script to find a certain string and print a certain occurrence.
I wrote this simple script that reads a text file and then adds the
I wrote a small script for work and when developing it everything was fine
As a simple example, I want to write a CLI script which can print
I wrote a script to export twitter friends as foaf rdf description. Now I'm
I wrote a script in Ruby. I'd like to run it every day at

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.