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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T09:04:30+00:00 2026-06-08T09:04:30+00:00

I have a problem reading a string in specific line and specific position. I

  • 0

I have a problem reading a string in specific line and specific position. I have an input file that has a fixed position and fixed length for each value in every row. This is an example of my input file:

sltele     Hoodie   24051988 d12Hdq
sltele     Hoodie   07051987 d30Hdq
sltele     Hoodie   07082011 d08Hdq
sltele     Hoodie   09081961 d04Hdq
sltele     Hoodie   20041962 d14Hdq
sltele     Hoodie   20032000 d01Hdq
sltele     Hoodie   13062002 d05Hdq

I need to read a string in 3rd column in first line. So, I used this

awk 'NR==1 {print $2, $3}' inputfile.inp

How can I get an exact result with character position as parameter? (12nd-18th and 21st-28th)

  • 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-08T09:04:32+00:00Added an answer on June 8, 2026 at 9:04 am

    use cut -c

    Check the man page for more details.

    also you can use the below:

    echo "abcdefghij" | awk '{print substr($0,2,2),substr($0,6,2)}'
    bc fg
    

    above is 2 characters from second position and 2 chars from 6th position.

    your solution will be :

    awk 'NR==1 {print substr($0,12,6),substr($0,21,7)}' inputfile.inp
    

    the above command will get the 6 chars from 12th position and 7 chars from 21st position in line number 1.

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

Sidebar

Related Questions

I have a file have multiple lines. For each line the format is String
I have a Java problem that involves reading a text file and check that
I have a problem reading a txt file to insert in the mysql db
In my assignment i have a problem with reading a file. See the following
I have a problem with reading empty string in C. I want to read
I am having a problem reading inputs, can anyone help me. Each line of
I have a problem with reading the EOF character for the last input in
I have this program that is reading the test string from a textbox and
I have a problem reading a comma-delimited TXT file. This is what I am
I have a problem with reading the image path of a string like ->

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.