Hello I have a windows 10 computer and am using Git Bash version 2.23.0. I am trying to learn how to write basic scripts following an online tutorial. The goal of this code would be to write the output to a different file as an html file. However the problem is that my 'du -s ~/../*' command never actually finishes.
#!/bin/bash
# This is an example
home_space()
{
cat <<- _EOF_
<h2>Space usage per user</h2>
<pre>$(du -s ~/../*)</pre>
_EOF_
}
cat <<- _EOF_
<html>
<head>
<title>Blah</title>
</head>
<body>
$(home_space)
</body>
</html>
_EOF_
Expected output file:
<html>
<head>
<title>Blah</title>
</head>
<body>
<h2>Space usage per user</h2>
<pre>0 /c/Users/me/../All Users
2714 /c/Users/me/../Default
0 /c/Users/me/../Default User
1 /c/Users/me/../desktop.ini</pre>
</body>
</html>
Instead it runs forever. When I try it on the command line the output is what I expect it to be but the shell prompt never returns unless I do a keyboard interrupt with CTRL-C.
My work around was just to use the timeout function, but I am curious why the du command doesn't just terminate on its own, and whether something is wrong?