Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

423
Vistas
How to remove the first 2 letters of multiple file names in linux shell?

I have files with the names:

Ff6_01.png
Ff6_02.png
Ff6_03.png
...
...
FF1_01.png
FF1_02.png
FF1_03.png

I want to remove the first two letters of every file name, because then I would have a correct order of the files. Does anyone know the command in the linux shell?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You can use the syntax ${file:2} to refer to the name starting from the 3rd char.

Hence, you may do:

for file in F*png
do
   mv "$file" "${file:2}"
done

In case ${file:2} did not work to you (neither rename), you can also use sed or cut:

for file in F*png
do
    new_file=$(sed 's/^..//' <<< "$file") <---- cuts first two chars
    new_file=$(cut -c3- <<< "$file")      <---- the same
    mv "$file" "$new_file"
done

Test

$ file="Ff6_01.png"
$ touch $file
$ ls
Ff6_01.png

$ mv "$file" "${file:2}"
$ ls
6_01.png
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda