I am trying to write a shell script to perform actions in the users home directory if it has a specific size. Unfortunately, when I try to use the read command to separate the output du -s, I get the "not found" command, because it tries to pass the number to the shell, and not to the variable as I want. Here is what I have done so far for the script.
#!/bin/bash
cd /home
for i in `ls`
do
j=`du -s $i`
k=`$j |read first;`
done
I get the output as follows:
./takehome.sh: line 6: 3284972: command not found
where 3284972 is the size of the directory.
source
share