![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help Required: Command to find IP address and command executed of a user | loggedout | Security | 2 | 08-06-2008 05:12 PM |
| how to? launch command with string of command line options | TinCanFury | Shell Programming and Scripting | 5 | 04-28-2008 03:06 PM |
| inconsistent ls command display at the command prompt & running as a cron job | rajranibl | Linux | 5 | 07-30-2007 05:26 AM |
| How to use more than one MPE command STREAM with Unix command in a single shell? | bosskr | HP-UX | 1 | 10-16-2006 01:16 PM |
| How to use more than one MPE command STREAM with Unix command in a single shell? | bosskr | Shell Programming and Scripting | 0 | 09-19-2006 06:44 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
command help
In the command ls -la | awk '{print $5}' the command ouput for size is left to right I need it to be right to left
|
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
How do you mean? The fifth field is the size field... I don't get the bit about left to right and right to left...
|
|
#3
|
||||
|
||||
|
Code:
ls -la | awk '{len = length($5) > len ? length($5) : len ; arr[NR] = $5 }END{ for ( a = 1; a < NR; a++ ) { printf "%"len"s\n" , arr[a]}}'
|
|
#4
|
|||
|
|||
|
Quote:
Quote:
If I may ask will you please explain it to me. Chris |
|
#5
|
|||
|
|||
|
Quote:
What I am actually trying to do is Code:
for f in $(<uploads); do
s=`echo "$PWD/$f" | sed -e 's/^.*chris\.fileburst\.com/chris.fileburst.com/'`
z=`ls -la "$f" | awk '{len = length($5) > len ? length($5) : len ; arr[NR] = $5 }END{ for ( a = 1; a < NR; a++ ) { printf "%"len"s\n" , arr[a]}}'`
x=`ls -la "$f"| awk '{print $6,$7,$8}'`
y=`md5sum "$f"| awk '{print $1}'`
echo -e "$s\t$z\t$x\t$y"
Is there a way to incorporate what you gave me into that. Last edited by reborg; 07-24-2006 at 04:31 AM. Reason: format the code |
|
#6
|
|||
|
|||
|
If anyone has any ideas I still really need help with this output. All the ideas I have had only works partially.
|
|
#7
|
||||
|
||||
|
I don't have time to explain this code right now, but will post again later, I may be able to correct mistakes, but that depends on time.
Code:
#! /bin/awk -f
#
# lineup.awk
#
BEGIN{
maxf = 0
}
{
sub ("^.*chris.fileburst.com", "chris.fileburst.com", $NF)
# may need to adjust to the correct ouput for your system
# keep values sequential
arr[NR,1] = $11
arr[NR,2] = $7
arr[NR,3] = $8
arr[NR,4] = $9
arr[NR,5] = $10
arr[NR,6] = $1
# make sure you keep the i < value one greater that the
# number of entries in the array, same in the END block
for ( i=1 ; i < 7; i++ ) {
if ( length(arr[NR, i]) > maxl[i] ) maxl[i] = length(arr[NR, i])
}
}
END{
for(x=1;x<=NR;x++){
for(y=1;y<7;y++){
if ( i == 2 ) {
printf("%"maxl[y]"s ", arr[x,y])
}
else {
printf("%-"maxl[y]"s ", arr[x,y])
}
}
printf("\n")
}
}
Code:
#!/bin/bash
while read file; do
do echo $(md5sum $file) $(ls -l $PWD/$file)
done < uploads | ./lineup.awk
|
||||
| Google The UNIX and Linux Forums |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|