Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

300
Views
rename files containing _2_ to -2- returns invalid option -- '2'

I am trying to rename all files containing _2_ to -2-

find ./ -depth -name "*_2_*" -exec /usr/bin/rename  _2_ '-2-' {} \+

but I get the following error:

/usr/bin/rename: invalid option -- '2'
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

This is a common problem when dealing with filenames that have a leading -, because this is the same character used to indicate command line options.

A fairly common behavior is to interpret the argument -- to mean "end of options", so you can do something like:

find ./ -depth -name "*_2_*" -exec /usr/bin/rename -- _2_ '-2-' {} \+

I've tested this locally and that seems to Do The Right Thing on my system.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!