You can use [the shell’s parameter expansion modifiers][1]:

 $ pathname="/home/paulo/paulo.pdf"
 $ filename=${pathname##*/}
 $ printf "%s\n" "$filename"
 paulo.pdf
 $ basename=${filename%.*}
 $ printf "%s\n" "$basename"
 paulo

`${pathname##*/}` is expanded to the contents of `pathname`, minus the longest prefix matching `*/`, *i.e.* the full path (if there is one). `${filename%.*}` is expanded to the contents of `filename`, minus the shortest suffix matching `.*`, *i.e.* the file’s extension (if there is one).


 [1]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02