Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I need to calculate the md5sum of one string per line in my ls dump:

directory_listing.txt:

./r/g4/f1.JPG
./r/g4/f2.JPG
./r/g4/f3.JPG
./r/g4/f4.JPG

However the md5sum should be calculated without the 'first dot'. I've written a simple script so far:

while read line
do
echo $line | exec 'md5sum'
done

./g.sh < directory_listing.txt

How can I remove the first dot from each line?

share|improve this question
    
Why not just generate the file without it in the first place? –  Ignacio Vazquez-Abrams Jul 6 '11 at 9:08
    
that file was not generated by me, so i cant. –  JosiP Jul 6 '11 at 9:09
    
exec isn't doing anything useful here -- just use echo "${line#./}" | md5sum. –  Gordon Davisson Jul 6 '11 at 14:36

2 Answers 2

$ foo=./abc/123
$ echo "${foo#./}"
abc/123
share|improve this answer

Change:

echo $line | exec 'md5sum'

to:

echo $line | cut -c 2- | exec 'md5sum'
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.