Saturday, June 6, 2009

Trim Filename Extension

Trim Filename Extension

There is built-in functionality in Linux shell to trim extension of a file name.
${filename_env_var%.ext} --> note that dollar ($) sign in the beginning is NOT shell prompt.

Usage example:
$ filename=trace_20090606.txt
$ echo ${filename%.txt}
trace_20090606 --> this is the output of previous command

No comments:

Post a Comment