Remove the file extension
clemou01
-
zipe31 Posted messages 34620 Registration date Status Contributor Last intervention -
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
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
-
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"
-
-
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 ;-)