Hello Gurus !
I have what probably amounts to a few simply changes to fix; however for the life of me I cannot seem to get it ti work. I need to align the output of my script (I am writing to a logfile)... here's the lines in my code:
if [ $header = "YES" ]
then
echo "NODE: $node" >> $logfile
echo " " >> $logfile
echo "Rule Permission Search" >> $logfile
echo " ID value Owner Group Location File type" >> $logfile
echo "------------------------------------------------------------------------------------------------------------------------------------" >> $logfile
header="NO"
fi
printf "%-10s%-7s%-8s%-8s%-10s%-34s%-10s\n" "$id" "$permval" "$owner" "$group" "$loc" "$file" "$stype">> $logfile
My output looks like this:
NODE: bat
Rule Permission Search
ID value Owner Group Location File type
-----------------------------------------------------------------------------------------------------
1 755 / ALL
3 755 testownertestgroup/ bat00043.bat FILE
10 755 /uscripts ALL
When it should look like this:
NODE: bat
Rule Permission Search
ID value Owner Group Location File type
-----------------------------------------------------------------------------------------------------
1 755 / ALL
3 755 testowner testgroup / bat00043.bat FILE
10 755 /uscripts ALL
Some things to note are that $owner, $group and $file may be NULL all other fields will have values. I think this is what is causing the issue. Is there wa way to tell unix (via printf, awk, sed or combination) to print a variable at a specific column regardless of it being NULL and it will not disturb other fields?
Thanks in advance to all that help out ... regards