I have to display the file name followed by the line count then work count. I am able to display it in the opposite order, but can figure out how to switch it.
Can anyone help me with this it would be greatly appreciated.
My code is as follows:
#!/bin/bash
#
#Conts and displays the filename, # of line and #of words
LSFILELIST=`ls -1`
for EACHFILE in "${LSFILELIST}"; do
echo `${EACHFILE}` | wc -lw ${EACHFILE}
done
That solution won't work with many shells, since they will run the read in a subshell. So that it will work correctly outside of ksh, you should echo from the same subshell.