0

Stuck trying to search if a file exists in a directory that's name has been imported from another txt file and if it exists to create a new one.

file="/home/user/data.txt"
while IFS= read line
do
    # display $line or do something with $line
    echo "$line"
    sudo mkdir -p /home/"$line"

    if [ -e "$line".txt]
    then
        echo "ok backup file exists"
    else
        echo "no backup file - one created"
        touch  ../home/"$line"/"$line".txt
    fi

errors are that the touch is not creating new file. Have created the input $line folders

Barmar
  • 741,623
  • 53
  • 500
  • 612
Bomber39
  • 1
  • 1

0 Answers0