You have been subscribed to a public bug:
Reading a file line by line gives unexpected result if a file contains
*/ or /*
File test.sh
-------------- begin
#!/bin/bash
while IFS='' read -r line; do
echo $line
done < $1
-------------- end
File test1.sh
-------------- begin
Ubuntu 1
Ubuntu /
Ubuntu 2
-------------- end
Command ./test.sh test1.txt outputs correct lines
Ubuntu 1
Ubuntu /
Ubuntu 2
File test2.sh
-------------- begin
Ubuntu 1
Ubuntu /*
Ubuntu 2
-------------- end
Command ./test.sh test2.txt outputs the list of the root folder!!! in addition
to lines in the file test2.txt
Ubuntu 1
Ubuntu /bin /boot /dev /etc /home /initrd.img /lib /lib64 /lost+found /media
/mnt /opt /proc /root /run /sbin /snap /srv /sys /tmp /usr /var /vmlinuz
Ubuntu 2
Each occurrence of /* adds the list of the root directory
Each extra /* adds one level of directories in the list of the root directory,
so eventually you can get the whole folder structure.
The combination */ causes output of the list of folders in the directory where
is the script is running from.
I am running the fresh installation
root@mxa:/etc/mail# uname -a
Linux mxa 4.4.0-62-generic #83-Ubuntu SMP Wed Jan 18 14:10:15 UTC 2017 x86_64
x86_64 x86_64 GNU/Linux
** Affects: ubuntu
Importance: Undecided
Status: Invalid
** Tags: linux shell
--
Reading a file causes directory list output
https://bugs.launchpad.net/bugs/1668237
You received this bug notification because you are a member of Ubuntu Bugs,
which is subscribed to Ubuntu.
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs