Extract file extension: Difference between revisions

→‎{{header|sed}}: Add sed solution
m (Minor grammar correction)
(→‎{{header|sed}}: Add sed solution)
Line 309:
file ext= [null] for file name=/path/to.my/file
file ext= [null] for file name=file.odd_one
</pre>
 
=={{header|sed}}==
<lang sed>s:.*\.:.:
s:\(^[^.]\|.*[/_]\).*::
</lang> or <lang bash>sed -re 's:.*\.:.:' -e 's:(^[^.]|.*[/_]).*::'</lang>
 
{{out}}<pre>.jpg
.png
.longextension
IAmAFileWithoutExtension
 
 
</pre>
 
57

edits