Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    How to get file extension (without the dot) ?


    I would like to know what is the extension of a file

    For example

    I'd like to put "txt" in a variable called ext

    I see in an other post
    echo <filename> | grep -o '\.[^.]*$'

    So I think I need to do something like
    ext=`echo $filename | grep -o '\.[^.]*$'`

    But I don't know how I should modify this to avoid the dot of ".txt"
    and to get only "txt" in $ext.

    Kind regards

  2. #2

  3. #3
    Thanks a lot
    I also have post the same question at
    How to get file extension (without the dot) -
    with differents answers

  4. $spacer_open
  5. #4
    This is Unix. There are many ways to get a thing done. That's why some love it and others hate it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts