Remove the file extension

clemou01 -  
zipe31 Posted messages 34620 Registration date   Status Contributor Last intervention   -
Hello,

I am currently looking to remove the extension from a file in shell. In fact, we were asked to truncate the names of the files at the extension level so that only the name is displayed (without the .blah). We were also told to use the tr function to do this.

Does anyone have an idea?

Here is my script:

#!/bin/bash

cd /home/Audit

for auditor in *

do
cd $auditor
pwd
ls

for files in *
do
report='echo $files|tr "." " "'
echo $report

done
cd ..
done

Configuration: Linux / Firefox 3.6.12

3 answers

  1. blux Posted messages 5036 Registration date   Status Moderator Last intervention   3 455
     
    Hi,

    check out the -d option of tr, it might give you a clue...

    --
    A+ Blux
     "Stupid people dare everything. That's even how we recognize them" 
    0
  2. clemou01
     
    After my research, all the possibilities I tried did not work.
    0
  3. zipe31 Posted messages 34620 Registration date   Status Contributor Last intervention   6 501
     
    Hi,

    I admit I've also explored many possibilities with "tr" without success ,-((

    Is it really the sine qua non condition (tr) to achieve this?

    The expansion of braces seems very appropriate for this kind of thing...
    ;-\
    --
    Zen my nuggets ;-)
    0