Sample Header Ad - 728x90

Read and write to file using bash

0 votes
2 answers
276 views
Problem statement: 1. Read a file line by line 2. Execute a command on each file 3. Print the line and output of command in another file **Input file (urls.txt):** www.google.com www.yahoo.com www.bing.com **Expected output file (output.csv):** www.google.com,200 www.yahoo.com,500 www.bing.com,404 **Script I have so far** while IFS= read -r line do curl -LI "$line" -o /dev/null -w '%{http_code}\n' -s >> output.csv done < urls.txt *not an expert in bash scripting. just a beginner. any help is much appreciated. Thank you. :)*
Asked by Jignesh144 (1 rep)
Mar 21, 2020, 05:56 PM
Last activity: Mar 22, 2020, 03:25 AM