ลองแบบนี้ น่าจะพอใช้แก้ปัญหานี้ได้ครับ

echo "http://www.somesite.org/some/path/here/and/the/filename.txt" | sed -e "s//.*// /" | cut -d' ' -f2

-วิภัทร