Article 5DDN2 Properly using redirection in script

Properly using redirection in script

by
SlowCoder
from LinuxQuestions.org on (#5DDN2)
I have the following script:

Quote:
#!/bin/bash

dir1=$(printf '%q' "$1")

echo Cataloging files that exist inside "$dir1"

# get list of all files within requested directory
allFiles=$(find "$1" -type f)

# get total number of files
numFiles=$(wc -l <<< "$allFiles")
echo Total files: "$numFiles"

# ERRORS START HERE
#echo $("$allFiles" | printf '%q' | stat -c "%10s %n")
#echo $(stat -c "%10s %n" <<< printf '%q' "$allFiles")
#echo $(printf "%q" "$allFiles" | stat -c "%10s %n")
$allFiles contains a list of files. I am trying to prepend the file size for each file. I've tried the 3 lines at the bottom, and I just cannot get it to work without 'stat' erring. I'm sure it's in the redirection methods I'm using.

Disclaimer: I'm sure there are plenty of utilities that do what I want. But I'm using this as an exercise to learn more about scripting, and in this case, redirection.latest?d=yIl2AUoC8zA latest?i=bp64vORkGr4:Y4htt38_gsY:F7zBnMy latest?i=bp64vORkGr4:Y4htt38_gsY:V_sGLiP latest?d=qj6IDK7rITs latest?i=bp64vORkGr4:Y4htt38_gsY:gIN9vFwbp64vORkGr4
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments