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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:12:57+00:00 2026-06-13T03:12:57+00:00

Many sources say that every instance of {} will be replaced with the filename

  • 0

Many sources say that every instance of {} will be replaced with the filename found through find, but when I try to run the following, I only get one text file and its name is “.txt”

find /directory -name "*pattern*" -exec cut -f8 {} > {}.txt \;

The goal was to create a text file with only the eighth column from each file found, and each text file will be named after its parent file. Something about that second set of {} is not replacing with the filename of each found file.

  • 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-13T03:12:59+00:00Added an answer on June 13, 2026 at 3:12 am

    Try:

    find /directory -name "*pattern*" -exec sh -c 'cut -f8 {} > {}.txt' \;
    

    But be aware that some versions of find require {} to be a distinct argument, and will not expand {} to a filename otherwise. You can work around that with:

    find /directory -name "*pattern*" -exec sh -c 'cut -f8 $0 > $0.txt' {} \;
    

    (this alternate command will put the output file in the subdirectory which contains the matched file. If desired, you could avoid that by redirecting to ${0#*/}

    The issue is that find is not doing the redirection, the shell is. Your command is exactly equivalent to:

    # Sample of INCORRECT code
    find /directory -name "*pattern*" -exec cut -f8 {} \; > {}.txt
    

    Note the following from the standard:


    If more than one argument containing only the two characters “{}” is present, the behavior is unspecified.

    If a utility_name or argument string contains the two characters “{}” , but not just the two characters “{}” , it is implementation-defined whether find replaces those two characters or uses the string without change.

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

Sidebar

Related Questions

I'm relatively new to unit testing, and I've discovered that while many sources say
I am a newbie in cryptographic system but i have seen many sources tell
Was overwriting a TextView class, and as I didn't find many sources, I was
I went through many lectures, videos and sources regarding Asymptotic notations. I understood what
I have a source of strings (let us say, a text file) and many
Yesterday I had a team leader of another team say that they took a
I have many source/text file, say file.cpp or file.txt . Now, I want to
Hi Masters Of Web Development, first I want to say that I did not
Say I find a very nice open source library in the internet and now
I have a Python project with many sub-modules that I package up with distutils.

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.