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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:52:55+00:00 2026-06-13T13:52:55+00:00

I have a C codebase, all resides in the same directory. I want to

  • 0

I have a C codebase, all resides in the same directory.
I want to find all the header files that have a code file with the same name.

Right now, I have the following command:

ls *.h | sed s/.h/.c/

This returns a ‘list’ of filenames that I want to search for. How can I pass this list to another command so that I can see which header files have code files sharing the same name?

  • 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-13T13:52:56+00:00Added an answer on June 13, 2026 at 1:52 pm

    Without any external command:

    $ for i in *.h
    > do
    >   [ -f  ${i/.h/.c} ] && echo $i
    > done
    

    The first line loops through every file.

    The third line is a test construct. The -f flag to test (aka man [) checks to see if the file exists. If it does, it returns 0 (which is considered true in shell). The && only operates if the following command if the previous line returned successfully.

    ${i/.h/.c} is an in-place in-shell regex substitution so that the file tested is the corresponding .c to the .h.

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

Sidebar

Related Questions

I have a codebase that I want to produce several deliverable jar files, each
we have quite a few projects that use the same codebase (backend code). Just
I have an existing code base that is not packaged at all. The code
I have this code to load a config file and read all the values
I have a working codebase that has a class called Tabs. All methods and
I have a very large codebase (read: thousands of modules) that has code shared
I have a huge codebase that has a lot of JAVA and .sql files.
I have a fairly large PHP codebase (10k files) that I work with using
I have a C++ legacy codebase with 10-15 applications, all sharing several components. While
I have inherited a DotNetNuke codebase and have come across areas that have included

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.