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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:41:43+00:00 2026-06-11T18:41:43+00:00

I have 2 files,fileA and fileB. fileA contains: 71 32 23 10 … and

  • 0

I have 2 files,fileA and fileB.

fileA contains:

71
32
23
10
...

and fileB contains:

ok
no
no
ok
...

What I want to do is deleting lines in fileA if the same line in fileB matches ‘no’.
So the resulting fileA would like:

71
10
...

Any command or bash script or vim can do this?

  • 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-11T18:41:45+00:00Added an answer on June 11, 2026 at 6:41 pm

    Here’s a quick one-liner that ought to do the trick:

    sed "$(awk '/no/{print NR"d"}' fileB)" fileA
    

    Where you put your regex to match where you see the word ‘no’ above.

    It works by scanning over the first with awk, and printing the line number followed by the letter ‘d’ of where the matches are. This pattern of nd is a sed command which deletes the nth line of an input stream.

    This version won’t modify the contents of fileA, but will print the result of removing the lines onto stdout. use the -i flag of sed to modify the file:

    sed -i "$(awk '/no/{print NR"d"}' fileB)" fileA
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the path /home/mine/new that contains files and sub directories. I want to
I'm trying to compile some C++ files that have the same name (fileA) but
I have two files: file1.txt and file2.txt . Both contains lines in this format:
hi guys i have two pipe delimited files,first file contains 1000 records and second
I have two Excel files contains the following structure, EmployeeAllDtl.xlsx id email name age
I have 100 text files which contains time series starting and ending at different
I have about 600 text files. Each file contains 2 columns and is space
I have a set of zip files which contains several ieee-be encoded binary and
I have huge amount of txt files which contains 64x64 matrices consisting of integers.
I have a folder which contains few files and some directories which I need

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.