Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

411
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda