I want to list all urls contain in all file of my project.
First function find_url_in_file
, work well –> I have this list
https://www.example.com/en/docs/console/my-project/how-to/add-resources-project
https://www.example.com/en/docs/console/my-project/how-to/generate-api-key
https://www.example.com/en/docs/console/my-project/how-to/delete-a-project
https://www.example.com/en/docs/console/my-project/how-to/join-an-organization
Then with second function find_all_url_in_file
, when it concat it remove all line jump :
https://www.example.com/en/docs/console/my-project/how-to/add-resources-projecthttps://www.example.com/en/docs/console/my-project/how-to/generate-api-keyhttps://www.example.com/en/docs/console/my-project/how-to/delete-a-projecthttps://www.example.com/en/docs/console/my-project/how-to/join-an-organization
I want to keep this line break to have a simple clean nice list. How could I do?
(maybe it’s a better idea to use a temp file ?)
all_mdx_file=$(find_all_mdx)
find_url_in_file(){
local file=""
local url_list=""
grep -Eo '(http|https)://www.xxxxxx.com[^ )>"]+' $file || : |
while IFS= read -r url; do
url_list+="$url"
done
echo "$url_list"
}
find_all_url_in_file(){
local file=""
local list_url=""
while IFS= read -r mdx; do
# echo "mdx read : $mdx"
url_in_this_file=$(find_url_in_file $mdx )
list_url+="$url_in_this_file "
done <<< "$file"
}
find_all_url_in_file "$all_mdx_file"