A simple bash one liner. I used this to remove rst extension from all files in pwd
for each in `ls -1 *.rst`
do
a=$(echo $each | wc -c)
echo $each | cut -c -$(( $a-5 )) >> blognames
done
What it does ?
1) ls -1 *.rst
will list all the files on stdout in new line (try).
2) echo $each | wc -c
counts the number of characters in each filename .
3) echo $each | cut -c -$(( $a-5 ))
selects up to last 4 characters, i.e, .rst
.