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 8585175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:59:40+00:00 2026-06-11T21:59:40+00:00

I have few text files that has some key words. I have to select

  • 0

I have few text files that has some key words. I have to select few lines from those files and parse it. Below is a sample file. I have to grep for “Customer” and get the line from the file.

13 Sun Sep  9 12:14:38 2012 : [P] Reproducer has the 167 number 
13 Sun Sep  9 12:14:38 2012 : [P] Customer has the 12.14.19.9 
13 Sun Sep  9 12:14:38 2012 : [P] Customer has the 12.14.89.9 
13 Sun Sep  9 12:14:38 2012 : [P] Reproducer has the 170 number 
13 Sun Sep  9 12:14:38 2012 : [P] Customer has the 12.4.89.16 

I have to select only the lines that has Customer and have to parse it to get only the Timestamp (12:14:38) and the Number 12.14.19.9. I have to do this for multiple files. All the file has the same structure of the log. I have done this using the oneliner like below

grep Customer Neigh.log | cut -d " " -f 5- | cut -d ":" -f 1-4 | cut -d " " -f 1,8

But I need to do this inside a shell script. How can I do this. Can anyone help?

Thanks

  • 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-06-11T21:59:41+00:00Added an answer on June 11, 2026 at 9:59 pm

    One way using GNU awk:

    for i in *.txt; do awk '/Customer/ { print $5, $NF > FILENAME".out" }' "$i"; done
    

    If you are using BSD awk:

    for i in *.txt; do awk '/Customer/ { out=FILENAME".out"; print $5, $NF > out }' "$i"; done
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

so I have some code that works fine with small text files but crashes
I have written a web app that has to save a few files. I
I have a 1.3GB text file that I need to extract some information from
I have a few text files and I'd like to count how many times
I have few text and excel file, from which I need to import data
I have the first few lines of a text file fx.txt with the following
I have a text file with a few 1000 lines of text in it.
I have a text file with few first few lines not required and then
Here's the problem -- I have a few thousand small text snippets, anywhere from
Pretty simple question. I have a few ASP RequiredFieldValdators checking some text boxes. Out

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.