First a note on style. Using a for loop and unquoted command substitution ($(...) or the ancient `...` form you're using here) to iterate over lines of output is rarely a good idea. TheUnquoted command substitution will split the output of the command on characters of for$IFS loop will split its input(space, tab and newline by default) and perform globbing on whitespacethe result so if you have more than a single space or tab delimited word per line, it will break each into a different variable.You should use And if some of those words contain wildcard characters such as while* instead since this deals with whitespace more gracefully. Also, it is generally preferred to use $(command)? instead, [...], that could be expanded to paths of matching files on the system.
You could use a `command`while IFS= read -r line loop instead to read the input line by line.
That is probably not your problem here though. The main issue is that you are echoing the resultsoutput of lsvgfs ${LINE} for each lineword resulting of resultsthe splitting (and globbing) of the output of lsvgfs ${LINE}:
for LINE2 in `lsvgfs ${LINE}` ; do echo "`lsvgfs ${LINE}` \n" done So, of course, you're getting these lines twice:
/ /usr Try this instead:
lsvg | while IFS= read LINE;-r vg; do echoprintf '%s\n' "Volume Group: ${LINEvg}" lsvgfs -- "${LINEvg}" | while IFS= read LINE2;-r fs; do echoprintf '%s\n' "File System: ${LINE2fs}" df -g $-- "${LINE2fs}" done echo "" echo done