Practice

Read file line by line

Here I read requirements.txt file to create an output file of commands and execute it

pip_install.sh

1
2
3
4
5
6
7
#! /bin/zsh
input="$1"
output="$2"
while read -r line; do
dep="$line"
echo "pip3 install $dep" >> "$output"
done < "$input"
1
2
3
sudo chmod 777 pip_install.sh
# execute commands in output.txt
bash output.txt