Article 5AAAC [SOLVED] Simple bash string manipulation - well it should be

[SOLVED] Simple bash string manipulation - well it should be

by
GPGAgent
from LinuxQuestions.org on (#5AAAC)
I have a file name, abcdefgh.mp4 and I want to just get the last four characters of the name "efgh" (okay - I know files in linux don't have extensions like in Windoze it's alll just part of the name)

I can do it with an intermediate variable, but I want one neat bit of bash:Code:$ echo $ff ${ff%.*}
5f391985dc5a423cb7d31.mp4 5f391985dc5a423cb7d31So far so good and I could do this:Code:$ X=${ff%.*}
$ echo ${X: -4}
7d31Or this, but it presumes the filenames are always the same length:Code:~$ ff=5f391985dc5a423cb7d31.mp4
~$ echo ${ff:17:4}
7d31But I would like a one liner pleaselatest?d=yIl2AUoC8zA latest?i=sZHR_Ty8-ws:opZp9dQUYOU:F7zBnMy latest?i=sZHR_Ty8-ws:opZp9dQUYOU:V_sGLiP latest?d=qj6IDK7rITs latest?i=sZHR_Ty8-ws:opZp9dQUYOU:gIN9vFwsZHR_Ty8-ws
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments