Greetings all,
I have a problem with the following code snippet:
I have a test directory ~/test_dir than contains two sub-directories /test_dir_1 and /test_dir_2, each containing two files.
Once the function is invoked
as expected.
To my consternation, the print statement outputs
as the value of the variable $line, during both runs through the loop, instead of the expected
and
respectively; however, the
The extension ine is from the last three letters of the variable $line, as I have confirmed by experimenting with the variable name. I have run the code via devel/hs-ShellCheck, without any indication of a problem.
Any insight in the discrepancy between the value of the variable $line as printed and used by the
Kindest regards,
M
I have a problem with the following code snippet:
sh:
tar_directory ()
{
if cd "$1"
then
find . -mindepth $2 -maxdepth $2 -type $3 > directories
if [ -s directories ]; then
while read -r line
do printf %s\\n "$1ine"
tar cvf "$line".tar "$line"
done < directories
rm directories
else
.
.
}
Once the function is invoked
tar_directory ~/test_dir 1 d
the directories file contains:
Code:
./test_dir_1
./test_dir_2
To my consternation, the print statement outputs
Code:
/home/user/test_dirine
Code:
./test_dir_1
Code:
./test_dir_2
tar cvf "$line".tar "$line"
correctly creates /test_dir_1.tar and /test_dir_2.tar.The extension ine is from the last three letters of the variable $line, as I have confirmed by experimenting with the variable name. I have run the code via devel/hs-ShellCheck, without any indication of a problem.
Any insight in the discrepancy between the value of the variable $line as printed and used by the
tar
would be appreciated.Kindest regards,
M