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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:57:06+00:00 2026-06-15T02:57:06+00:00

How could I write a Linux shell script to check the contents of a

  • 0

How could I write a Linux shell script to check the contents of a directory to see if a file with the same name already exists?

The directory/location to be checked would be obtained from a file /root/TAM/store using the grep function.

The contents of store is the directory’s of files which I have moved to a dustbin in a previous script, It stores the directory they were in before the mv

the input is just the name of the file in dustbin that you want to restore to its original location, If i file exists it should ask you to rename or chose a new dir

  • 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-15T02:57:07+00:00Added an answer on June 15, 2026 at 2:57 am

    If the file /root/TAM/store has just a line with the directory to search, you can do as follows

    if ls `cat /root/TAM/store` | grep -q filename_to_look_for; then
        echo "filename_to_look_for exists"
    else
        echo "filename_to_look_for doesn't exist"
    fi
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to check if a process complete or not by shell script (linux
Why does eclipse break with the error Could not write file: M:\workspaces\eclipse\project.project. M:\workspaces\eclipse\project.project (Access
I am writing a mathematica script and running it in the linux batch shell.
I currently working with embedded linux with bash shell on it. Write now I
are there any libraries for Linux wrote with C++, that could register global hotkeys
Sure I could write this myself, but before I go reinventing the wheel is
Is there a piece of code I could write to be notified when a
If you have a C function which returns an integer, you could write a
i'm using DbSimple, but there is some code which i could write into another
How could i write word on the web, and save the content to 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.