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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:00:49+00:00 2026-05-30T21:00:49+00:00

Extract a particular column value from multiple files ls -ltr -rwxr-xr-x 4 dc staff

  • 0

Extract a particular column value from multiple files

ls -ltr

-rwxr-xr-x   4 dc staff   131 Feb 27 21:15 test.txt
-rwxr-xr-x   4 dc staff   134 Feb 25 21:15 test1.txt

test.txt and test1.txt (similar structure) contains a table structure like

cat test.txt

RECORD #1 DETAILS

    sl no.  regno  name  age
     1       20    ABC   10

cat test1.txt

RECORD #2 DETAILS

      sl no.  regno  name  age
       1       21    DEF   11

I want to extract the 2nd column value from all .txt files and store it into some other files.

Ouput.txt should be

test.txt 20
test1.txt 21
  • 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-30T21:00:50+00:00Added an answer on May 30, 2026 at 9:00 pm

    It’s not exactly clear what you are looking for, but if you just want to print the second column of the 4th line (and that is the ambiguity, as it’s not clear if you always want the data from line 4, or the data from 3 lines after ^RECORD, or data from the line after each occurrence of "sl no.", etc), you could do:

    $ awk 'FNR == 4 { print FILENAME, $2 }' test.txt test1.txt
    

    or, if you are using an awk that does not support FILENAME (at the moment, I’m not sure if that is standard or a gnu extension) and you are not using csh or one of its cousins, you could do:

    $ for n in test.txt test1.txt; do printf '$s ' $n; awk 'NR==4{ print $2}' $n; done
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to extract all instances of a particular format from a string:
Extract from CLR via C# on Boxing / Unboxing value types ... On Boxing:
I extract the audio from a bunch of flv files as an MP3. This
how can extract all the words that start with a particular letter from wordnet.
I'm trying to extract an element with a particular innertext from a parsed XML
I need to extract a single keyframe from a video of a particular human
I'm using ABCpdf to extract the text content of some PDF files, in particular
On a Mac, I can extract the Persistent ID for a particular song from
I want to extract a particular fields from a csv file (830k records) and
How to extract the value represented by a particular set of bits in a

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.