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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:10:06+00:00 2026-06-10T23:10:06+00:00

I am trying to use awk to read some input at the field position

  • 0

I am trying to use awk to read some input at the field position at 3, $3, field 3 is a string

awk -F'","' '{print $1}'  input.txt

my file input.txt looks like this

field1,field2,field3,field4,field5

the problem is that these fields are separated by commas, some of them are double quoted while others are not. And field 5 is double quoted and contains every type of symbols. Example:

imfield1,imfield2,"imfield3",imfield4,"im"",""fi"",el,""d5"

can awk handle a situation like this??
In more gner, how can I get the whole string by typIng $5 ?

  • 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-10T23:10:08+00:00Added an answer on June 10, 2026 at 11:10 pm

    You can use Lorance Stinson’s Awk CSV parser, in which case it’s as simple as:

    function parse_csv(..) {
        ..
    }
    
    {
        num_fields = parse_csv($0, csv, ",", "\"", "\"", "\\n", 1);
        print csv[2]
    }
    

    If you’re not hell-bent on Awk, Python also comes with a nice CSV parser:

    import csv, sys
    
    for row in csv.reader(sys.stdin):
        print row[2]
    

    Or from the command line (bit tricky in one line):

    python -c 'import csv,sys;[sys.stdout.write(row[2]+"\n") for row in csv.reader(sys.stdin)]' < input.txt
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to edit a text file that looks like this: TYPE=Ethernet HWADDR=00:.... IPV6INIT=no
I have an input file that looks like this (first column is a location
I am trying to use awk as some types of element counter as follows,
I have output with this format: /ignore-this/^/../I/want/this@ignore-this I am trying to use an awk
I'm trying to use awk to add up the numbers from an output file,
I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
Hi I'm trying use a datepicker on a field I have. I'm trying to
I am need paint my image. I'm trying use JQuery in here this link:
I'm trying to use grep to go through some logs and only select the
I'm trying to use a simple perl one-liner on the following input: @F7##########0/1 C4CTA6GCAAC56G67CTCA99C

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.