Search This Blog

Shell Script: remove file extension

  • Use sed:
    echo "file.txt" | sed 's/\(.*\)\..*/\1/'
    
  • Use bash string operations:
    f="filename.txt"; echo "${f%.*}"
    

No comments:

Post a Comment