Solved Creating a list of packages sorted by timestamp

astyle

Daemon

Reaction score: 662
Messages: 1,490

I'm trying to create a list of installed packages, sorted by timestamp... And I came up with a script, but it's not working right:
Bash:
for port in `cat ../lists/kde_ports.txt`;
do
    pkg query %t $port | awk '{ print $1"    " $2}' | sort > ../lists/sorted_kde_ports.txt ;
done

%t is the timestamp, and it needs to correspond to $1. $port needs to correspond to $2. That way, the output can be sorted properly.

FWIW, this is a 6-year-old issue, discussed on FreeBSD's email lists... and not solved.

I'm open to using sed or whatever instead of awk, if that helps. If somebody can correct my script, I'd appreciate this!
 

julp

Member

Reaction score: 38
Messages: 65

Code:
#!/bin/sh

(
    for port in `cat ../lists/kde_ports.txt`;
    do
        echo `pkg query %t "${port}"` "${port}"
    done
) | sort > ../lists/sorted_kde_ports.txt
?
 
OP
astyle

astyle

Daemon

Reaction score: 662
Messages: 1,490

Code:
#!/bin/sh
(
    for port in `cat ../lists/kde_ports.txt`;
    do
        echo `pkg query %t "${port}"` "${port}"
    done
) | sort > ../lists/sorted_kde_ports.txt
?
Wow, that was fast! Gonna check it out on my machine to see if it helps! Thanks! :)
 
OP
astyle

astyle

Daemon

Reaction score: 662
Messages: 1,490

WOW... that was exactly what I needed! I could have spent hours googling and reading manuals instead, and still not have it right... Thanks, julp !
 

jb_fvwm2

Daemon

Reaction score: 209
Messages: 1,843

I found pkg query %t-%n | sort ... checking the man page and
a bit of conjecture... maybe useful here, or to others...
 
Top