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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:52:49+00:00 2026-05-13T15:52:49+00:00

here’s my situation: I had a big text file that I wanted to pull

  • 0

here’s my situation: I had a big text file that I wanted to pull certain information from. I used sed to pull all the relevant information based on regexp’s, but each “piece” of information I pulled is on a separate line, I’d like for each “record” to be on its own line so it can be easily imported into a DB.
Here’s a sample of my data right now:

92831,499,000
,0644321
79217,999,000
,5417178
,PK91622
,PK90755

Ideally, I would want this output to look like:

92831,499,000
,0644321
79217,999,000
,5417178
,PK91622
79217,999,000
,5417178
,PK90755

This may be harder to do, so I would settle for the output of that last “record” to only appear once with the additional “PK…” to be the 4th “field” of that line.
In the end, the simplest way I could think of doing is if the line starts with a comma ( ^, ) the newline before it should be removed… I’m not too familiar with awk though so if you could give me a start on this it would really be appreciated! 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-05-13T15:52:50+00:00Added an answer on May 13, 2026 at 3:52 pm

    Well, guess I should have taken a closer look at using Records in awk when I was trying to figure this out last night… 10 minutes after looking at them I got it working. For anyone interested here’s how I did this:
    In my original sed script I put an extra newline infront of the beginning of each record so there’s now a blank line seperating each one. I then use the following awk command:

    awk ‘BEGIN {RS = “”; FS = “\n”}
    {
    if (NF >= 3)
    for (i = 3; i <= NF; i++)
    print $1,$2,$i
    }’

    and it works like a charm outputting exactly the way I wanted!

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

Sidebar

Related Questions

Here is the script I'm using, copied directly from Google: <script type=text/javascript> var _gaq
Here's my situation. I've noticed that code gets harder to maintain when you keep
Here's the situation, i want to have a user that can enter time on
Here what I would like to pull date from this three table. Table users
Here is the Javascript I currently have <script type=text/javascript> $(function() { $('.slideshow').hover( function() {
Here's what I'm trying to accomplish with this program: a recursive method that checks
Here's some of my production code (I had to force line breaks): task =
Here's the setup - I have a view that lists products. On that same
Here's my situation. I have a DotNetNuke application. I want to link to an
Here is the situation. I am making changes to an application but I do

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.