Tuesday, August 3, 2010

File extension in shell

FILENAME="file.txt"


  1. To print file's extension:

    $ echo ${FILENAME#*.}

    txt

  2. To print file name without extension:

    $ echo ${FILENAME%.*}

    file


No comments:

Post a Comment