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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:06:21+00:00 2026-05-31T18:06:21+00:00

I have a folder with multiple sub-folders and each sub-folder contains 10-15 files. I

  • 0

I have a folder with multiple sub-folders and each sub-folder contains 10-15 files. I want to perform a certain operation only on the text files in these folders. The folders contain other types of files as well. For now, I am just trying to write a simple for loop to access every file.

for /r in *.txt; do "need to perform this on every file"; done

This gives me an error -bash: ``/R': not a valid identifier

Thanks for the help.

P.S I am using cygwin on Win 7.

  • 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-05-31T18:06:22+00:00Added an answer on May 31, 2026 at 6:06 pm

    Your /r is the problem, that’s not a valid identifier (as bash said, you need to drop the /). Also, this won’t recurse into subdirectories. If your operation is simple, you can directly use the exec option of find. {} is a placeholder for the filename.

    find . -name "*.txt" -exec ls -l {} \;
    

    Otherwise, try something like

    for r in $( find . -name "*.txt" ) ; do
        echo $r
        #more actions...
    done
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Inside my main folder, I have multiple sub-folders and each sub folder contains multiple
I have multiple files in a folder and each of them have one email
I have a folder with multiple files, and I'd like to remove all <script>
I have multiple websites set up in the same folder, and I want to
I would like to have multiple files in a folder with are managed by
I have multiple sub-domains within the document_root. And multiple folders/classes within those sub-domain folders.
I have many text files in a folder. What I can do now is
I have multiple XML files in a folder,so I written script like this to
I am going to have one directory with multiple sub-directories. I want to be
I have a folder that contains multiple executables. Currently the assembly binding redirect is

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.