-2

So here is my problem when using code:

for i in filename.txt
do
    <operations>
    done

Operations are being made on both file contents as well as filename itself, why is that happening?

Just to be clear I alread got 2 solutions that solve this problem, but I still can't understand why is that happening. One of the solutions that have worked for me:

for i in $(cat filename.txt)
do
    tar -czf ${i}.tar $i
rm -R $i
gzip $i.tar
    done

1 Answers1

0

"Yes. In for i in filename.txt you will have one $i and it will be set to filename.txt. If you want to read the contents of $i - do that in the loop." Thank you Ted Lyngmo.