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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:36:00+00:00 2026-06-03T11:36:00+00:00

I have two sets of text files. First set is in AA folder. Second

  • 0

I have two sets of text files. First set is in AA folder. Second set is in BB folder. The content of ff.txt file from first set(AA folder) is shown below.

Name        number     marks
john            1         60
maria           2         54
samuel          3         62
ben             4         63

I would like to print the second column(number) from this file if marks>60. The output will be 3,4. Next, read the ff.txt file in BB folder and delete the lines containing numbers 3,4. How can I do this with bash?

files in BB folder looks like this. second column is the number.

   marks       1      11.824  24.015  41.220  1.00 13.65 
   marks       1      13.058  24.521  40.718  1.00 11.82
   marks       3      12.120  13.472  46.317  1.00 10.62 
   marks       4      10.343  24.731  47.771  1.00  8.18
  • 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-03T11:36:01+00:00Added an answer on June 3, 2026 at 11:36 am

    This works, but is not efficient (is that matter?)

    gawk 'BEGIN {getline} $3>60{print $2}' AA/ff.txt | while read number; do gawk -v number=$number '$2 != number' BB/ff.txt > /tmp/ff.txt; mv /tmp/ff.txt BB/ff.txt; done
    

    Of course, the second awk can be replaced with sed -i


    For multi files:

    ls -1 AA/*.txt | while read file
    do
        bn=`basename $file`
        gawk 'BEGIN {getline} $3>60{print $2}' AA/$bn | while read number
        do
            gawk -v number=$number '$2 != number' BB/$bn > /tmp/$bn
            mv /tmp/$bn BB/$bn
        done
    done
    

    I didn’t test it, so if there is a problem, please comment.

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

Sidebar

Related Questions

I have two sets of text files. First set is in AA folder. Second
I have two Sets. Set b is the subset of Set a . they're
I have two sets of vectors, set A and set B. Let's say set
I have a program that compares variables from two structs and sets a bit
I have two sets of identical html and css files. One of which I'm
I have two views with navigation controller: first view, there are empty text fields
I have an InputStream that would read from a text file. I noticed that
I have two converters, one sets the control visibility to Hidden if the text
I have two threads running from a controller class. The first thread receives SMS
I have a form that consists of: 3 text boxes (first two are required

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.