gpt-4.1-mini-2025-04-14· OpenAI
LMArena Human Preference 140K
How do I get the file name without extension in the find command with -exec?
- User
How do I get the file name without extension in the
findcommand with-exec? - Assistant
If you want to use
findwith-execand get the filename without the extension, you can do this by invoking a shell to manipulate the filename.Example
Suppose you want to find all
.txtfiles and print their names without the.txtextension.find . -name "*.txt" -exec sh -c 'f="{}"; basename="${f##*/}"; echo "${basename%.txt}"' \;
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.