Remove first character of a string in Bash Ask Question

Remove first character of a string in Bash Ask Question

I need to calculate md5sum of one string (pathfile) per line in my ls dump, directory_listing_file:

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

But that md5sum should be calculated without the initial dot. I've written a simple script:

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

./g.sh < directory_listnitg.txt

How do I remove the first dot from each line?

ベストアンサー1

myString="${myString:1}"

Starting at character number 1 of myString (character 0 being the left-most character) return the remainder of the string. The "s allow for spaces in the string. For more information on that aspect look at $IFS.

おすすめ記事