split url path with parameters and extension awk and grep code example Example: extract path from url sed $ grep -Po '\w\K/\w+[^?]+' <<<$url /one/more/dir/file.exe