I have written a bash script that calls a Python script to scan for a vulnerability:
#scan.sh
while IFS=, read -r n d ;do
python scan.py $d 443 | sed "s/^\(.\)/$n,\1/"
done < Input.csv
Input.csv looks like:
#Input.csv
1,abc.com
2,xyz.com
3,pqr.com
.........
Output.csv should look like:
1,abc.com,True,2016-03-06
1,abc.com,False,2016-03-06
1,abc.com,True,2016-03-06
1,abc.com,True,2016-03-06
2,xyz.com,False,2016-03-06
2,xyz.com,False,2016-03-06
2,xyz.com,False,2016-03-06
2,xyz.com,False,2016-03-06
3,pqr.com,True,2016-03-06
3,pqr.com,True,2016-03-06
3,pqr.com,True,2016-03-06
3,pqr.com,True,2016-03-06
........................
Each ID will have four entries in the output.csv with varying results.
- If any of the four entries for an
IDisTrue, it has to beTrueand need to have one entry for aID. - If all four entries for an
IDareFalse, it has to beFalseand with one entry. - If all four entries for an
IDareTrue, it has to beTrueand with one entry.
Thus:
# processed_out.csv
1,abc.com,True,2016-03-06
2,xyz.com,False,2016-03-06
3,pqr.com,True,2016-03-06
........
How can I achieve this case only by using awk/sed?
FYI : I'm a beginner in bash scripting.