Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Output Presentation

Status
Not open for further replies.

jdhinze

MIS
Jul 14, 1999
35
US
<br>
I am new to awk. Below is the awk statament I am using trying to have end result on one line for each directory.<br>
<br>
<br>
awk ' substr($0,1,1) &gt; " " { printf \ <br>
"echo -n b1/bak/%s ;ls -l /b1/bak/%s¦wc -l ;du /b1/bak/%s \n",\ <br>
$1,$1,$1,$1}' $NUM &gt; $JOB <br>
1,$1}' $NUM &gt; $JOB <br>
<br>
<br>
Output<br>
b1/bak/189 3 <br>
101588 /b1/bak/189 <br>
b1/bak/190 3 <br>
101610 /b1/bak/190 <br>
b1/bak/191 3 <br>
101590 /b1/bak/191 <br>
b1/bak/192 1 <br>
<br>
Desired Output<br>
<br>
b1/bak/189 3 101588 /b1/bak/189<br>
b1/bak/190 2 101610 /b1/bak/190<br>

 
I am not really sure what you are trying to accomplish, but the reason you have the "extra" newline is due to the 'wc'.<br>
But if what you are trying to do is list the number of entires in a directory, and then the number of blocks, I would suggest the following shell script:<br>
<br>
for dir in ${*}<br>
do<br>
print ${dir} $(find ${dir} -print ¦ wc -l) $(du ${dir})<br>
done<br>
<br>
[assuming ksh, and not really tested]<br>
<br>
If you system supports it, use 'printf' instead of 'print' to format things "better" (subjective term :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top