Hello.
Here my very basic script
I have a list filled with random URLs
Example
http://www.bbc.com/news/world-europe-27266922
http://www.weeklystandard.com/articles/their-911-role_794957.html
http://www.theguardian.com/global-development/2014/jun/10/supermarket-prawns-thailand-produced-slave-labour
I need to place each URL in separate txt file with name contains the same URL (I know about filesystem limitation)
So I need to replace slashes with underscore
Code:
#!/bin/bash
#This script create a multiple txt files with names and contents, which imported from file with URLs
#echo "Usage url2txt.sh < filename_with_URL.stxt"
while read line ; do
touch 1.txt
echo $line > 1.txt;
sed 's/\//_/g' $line > $line;
mv 1.txt $line.txt
rm 1.txt;
done
But i stuck with sed.
If I manual sanitize file with URL - all works. File created, sanitized URL placed into file, but i need unsanitized URL in file :)