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

  • Home
  • SEARCH
  • 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 8520557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:34:07+00:00 2026-06-11T06:34:07+00:00

How do I check (with the shell) if a file with the file-extension .ini

  • 0

How do I check (with the shell) if a file with the file-extension .ini exists in /dir?
What would be the fastest way? Thanks!

  • 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-11T06:34:09+00:00Added an answer on June 11, 2026 at 6:34 am
    set -- /dir/*.ini
    case $1 in
      ('/dir/*.ini') echo "No ini files here.";;
      (*)            echo "Found $# ini files: $@";;
    esac
    

    Look ma! No forks! This should beat, by a million of CPU cycles, any solution with forks to ls, find and friends.

    Now there’s one little gotcha here. Can you spot it? Okay, what happens if /dir contains a file named *.ini literally (star, dot, ini)? The above will give you a false negative: it reports no ini file although there is one. If you want to prepare for this case (and you should, because you are a careful programmer, giving attention to detail, no gotchas in your code, right?), you slightly modify the first case to read

    ('/dir/*.ini')
      if test -f '/dir/*.ini'; then
        echo "Wow, there's a plain file named '/dir/*.ini'!"
      else
        echo "No ini files here."
      fi;;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I check the file encoding in a shell script? I need to
How do I check if a file is an image in applescript or shell
I am writing some BASH shell script that will continuously check a file to
Given a file path (e.g. /src/com/mot ), how can I check whether mot exists,
I'm trying to programmatically check file associations by the file extension (for example .jnlp
In ksh shell, I wanna to check the return value after running a command,
I'm writing a shell script that before running needs to check that system Perl
I was requested to make a shell script to check for simple mistakes in
Does anyone know of a C# spell check library that would underline misspelled works
I've written a shell extension using EZShellExtensions.net. It works great in my development environment

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.