Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
Hello all, I have posted here before and really was blown away by the amount of assistance I received. I was able to finish my homework without a problem! But, yet again, our instructor has given us an assignment a lot of agreed was a bit too advanced for us. I'm in need of some help.
1. The problem statement, all variables and given/known data:
Create a shell script to loop through all the files and display
Sequence # Name Size Flag
========== ====================== ========= ==============
Flag should be "Yes" for executable files and "No" for non-executable files.
2. Relevant commands, code, scripts, algorithms:
ls, grep, printf, while loop
3. The attempts at a solution (include all code and scripts):
Here's my sad attempt at it:
s=1
while [ $s -le 10 ]
do
printf "Sequence\n========\n%4d\n" $s
name=`cut -d" " -f1 RevFile | rev`
printf "Name\n===========\n%4s" $name
size=`ls -l | awk -F" " '{print $5}'`
printf "Size\n===========\n$4s" $size
printf "Flag\n==========\n"
let s++
done
WHAT WORKS:
The Sequence has no problem incrementing to the number I indicated. I set it up as a test because I knew the directory we were using contained hundreds of files and I wanted to keep it at a low number. File names are also showing up, but that's it, and even they are having problems lining up correctly under the "=======".
The "rev" command is in place because I actually had a file already set up with the directory in reverse so if I needed file names all I had to do was cut that first field, reverse that, and I had it. I'm sure there's an easier and better method out there, such as awk, but I've allowed frustration of not knowing what to do to get to me.
What is NOT working:
File size isn't showing up as intended and I don't have the flag portion set up. I need to get this thing straightened out first before I start working on the actual fields because right now it's printing as one whole single line and seperating into columns like the instructor is wanting us to do. I gotta be honest here, the guy HAS NOT covered enough material for us to be able to pull something like this off.
So basically I'd like to know what I should be doing in order to line the columns up the way they need to be. I'd be extremely grateful for any and all help!!!!
4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
Baker College of Jackson, Jackson MI, U.S., Instructor S. Sadiq, LUX 211
Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).