user1857016 user1857016 - 6 months ago 30
Linux Question

Using Sed to remove only first character in file name if it's alphabetical

I have bunch of files in a folder which I need to copy with another name in case, that if file first charcter is alphabetical, then remove this character and leave all other character asis either those are numbers, alphabeticals, special marks or what ever. So few exsapmles:

R123456.txt --> should be copied as 123456.txt

Y1235465.jpeg --> should be copied as 1235465.jpeg

736628487.txt --> do nothing

I have used this command:

for file in * ; do cp $file $(echo $file |sed 's/[A-Za-z]//g'); done

But this removes also file extensions which I would like to leave as is...





At the start of the buffer a single alphabetic character