I have a CSV file which contains the data in the following format
web_url.csv
drive,http://www.drive.google.com/
wikipedia,https://en.wikipedia.org/wiki/%s
wolframalpha,http://www.wolframalpha.com/input/?i=%s
I would like to create a directory for each item in the first column and inside that directory create a text file with the same name as the directory. ie: it should create a file structure as shown.
├───drive
│ - drive.txt
│
├───wikipedia
│ - wikipedia.txt
│
└───wolframalpha
- wolframalpha.txt
The file contents of each of the file should be as shown below
#!/bin/bash
echo [$@]
echo "command=xdg-open \" $url $@\""
echo "icon="
echo "subtext=Search on $keyword for $@"
where the $url is replaced by the item in the second column and the $keyword is being replaced by the item in the first column.
Edited:
awk -F "," '{print $1,$2}' web_url.csv | awk '{system("mkdir "$1)}'
awk -F "," '{print $1,$2}' web_url.csv | awk '{print $1 > $1".txt"}'
test.sh
key=`awk -F "," '{print $1}' web_url.csv`
search_url=`awk -F "," '{print $2}' web_url.csv`
for word in $key; do
echo 'echo "command=xdg-open \"$url$@\""'
echo 'echo "icon="'
echo "echo "\"subtext=Search on $word for \$@""\"
done
Output
echo "command=xdg-open \"$url$@\""
echo "icon="
echo "subtext=Search on wikipedia for $@"
echo "command=xdg-open \"$url$@\""
echo "icon="
echo "subtext=Search on wolframalpha for $@"
echo "command=xdg-open \"$url$@\""
echo "icon="
echo "subtext=Search on drive for $@"
I am not sure how to create the file inside the folder and how to create the file contents for each file and not have the contents in a single file as shown in the output above.
Also in the output I am not getting the url there.