I want to make a script that creates files in selected directory.
list is the list of names input by user when executing shell file
bash shell.sh file01 file02 file03
then "for" should create three files in pre-set directory under the names of file01, file02 and file03.
list=($1 $2 $3 $4)
for i in $list
echo "Created file: $list"
touch /home/paulius/Desktop/shell $list
All this code does is creates one file and echoes Created file: file01. And that is it. What is wrong in the code?
Also, reading the variables from file "list.txt" would be even better. How could I do that?
if test -s /home/paulius/Desktop/shell/shell_testas/sarasas.txt
for line in $(cat sarasas.txt)
if test -d /home/paulius/Desktop/shell/shell_testas
echo "Created file: $line"
touch /home/paulius/Desktop/shell/shell_testas $line
echo "No such directory"
echo "Empty list"
Works great for me situation.