This is a long-shot however, I am stuck with the following problem:
I have the output from ls -la, and I want to sort some of that data out by using AWK to filter it.
ls -la | awk -f scriptname.awk
Input:
I wanted to sort out:
- The smallest filesize ($5)
- The biggest filesize ($5)
- The oldest file ($6 & $7?)
- The newest file ($6 & $7?)
I'm really sorry and ashamed that I can't make this script myself. I've been trying to figure it out for the last day, and I just can't . I really tried a lot of options, and also the old-fashion way of writing in text what the program should do and then write it out in code, however I just don't know where to start. I guess my sense of logic is failing miserably.
I really, really hope someone can help me out.
- Mario de Rooy (Netherlands)
---------- Post updated at 09:58 AM ---------- Previous update was at 09:52 AM ----------
My general logic was:
Last edited by abciscool; 04-12-2010 at 07:06 AM..
Reason: Adding context.
Thank you so much for you help, if it works it will cover already half of what I wanted to achieve (which is a lot!! ).
To recap, for thought-process:
If I read it correctly;
At the second record set the variables min and max to the value of the 5th field. Then at every record past the second one do;
- if the min-variable is greater than the value of the 5th field, set the variable min to the current value of the 5th field.
- if the max-variable is smaller than the value of the 5th field, set the variable max to the current value of the 5th field.
At the END print the min- & max- variables current value in the output.
Is my clarification of this code correct, or am I missing some aspects?
Thank you so much for you help, if it works it will cover already half of what I wanted to achieve (which is a lot!! ).
To recap, for thought-process:
If I read it correctly;
At the second record set the variables min and max to the value of the 5th field. Then at every record past the second one do;
- if the min-variable is greater than the value of the 5th field, set the variable min to the current value of the 5th field.
- if the max-variable is smaller than the value of the 5th field, set the variable max to the current value of the 5th field.
At the END print the min- & max- variables current value in the output.
Is my clarification of this code correct, or am I missing some aspects?
In the below I am trying to use awk to match all the $13 values in input, which is tab-delimited,
that are in $1 of gene which is just a single column of text.
However only the line with the greatest $9 value in input needs to be printed.
So in the example below all the MECP2 and LTBP1... (0 Replies)
`awk` function looks like this in a file name `fun.awk`:
{
print small()
}
function small()
{
a=$0
smal=0
for(i=1;i<=3;i++)
{
if( a<a)
smal=a
else (4 Replies)
Hi All
I need to find the smallest values between replicates id (column1)
Input file:
a name1 1200
a name2 800
b name1 100
b name2 150
b name3 4output:
a name2 800
b name3 4
Do you have any suggestion?
Thank you! (9 Replies)
Hi !
Here is an example of a tab-delimited file with variable width values in field 2 (space separated values).
As the real file contains lot of lines, I can adjust manually the width to the largest value in field 2.
Does it exist an argument to do it automatically?
input.tab:... (4 Replies)
I have two text files like this:
file1.txt:
133 10
133 22
133 13
133 56
133 78
133 98
file2.txt:
158 38
158 67
158 94
158 17
158 23
I'm basically trying to have awk check the second largest value of the second column of each text file, and cat it to its own text file. There... (13 Replies)
Hi All,
My file is like this:
$ cat max.txt
abcd:1982:a
efghij:1980:e
klmn:1923:k
opqrst:1982:o
I have to find out the largest first field and the corresponding line. i.e
Output required:
efghij efghij:1980:e
opqrst opqrst:1982:o
HTH,
jkl_jkl (6 Replies)
Hey. This is pretty easy stuff but I'm learning the basics of Unix at the moment so keep that in mind. I have to:
1) Write a C-shell script to monitor user activity on the server for 13 minutes.
2) Then print the smallest and largest number of users during these 13 minutes.
I have this:
1)... (2 Replies)
Hi All,
My script is reading a log file line by line
log file is like ;
19:40:22 :INFO Total time taken to Service External Request---115ms
19:40:25 DEBUG : Batch processed libdaemon.x86_64 0-0.10-5.el5 - u
19:40:22 INFO Total time taken to Service External Request---20ms
19:40:24... (4 Replies)