Hi Everyone,
I am reading in a list of IDs from a file that is is chronological order. My current code in simplified form looks like this (ksh by the way)
IDS=`awk -F\| '{print $1}' inputfile.txt`
for i in $IDS
do
do various things with that ID
done
What I would like to do is start with the last ID (10000) and work towards the first ID (1). This is an oversimplified example. There are gaps between IDs, the may not be consecutive. I cannot do a while loop starting with i=10000 and decrement to 1 due to this. Any ideas how I could reverse the values in $IDS before the for loop? The input file can be manipulated prior to calling the script. I thought there was a command to invert a list but I can't remember what it is and can't find it ( I searched the forum + google + man -k)
Thanks,
Tony
Don't you hate when you search for ever, can't find the answer, then as soon as you ask someone else, you find it. The command I was think of was 'rev'. However, I still need some help if you can offer it. rev exists on my HPUX box but not on my Solaris box where the script runs. Anyone know where I can get a similar binary for Sun?
I thought about using nl when I wrote the sed script but then thought I could just use sed without having to add the numbered lines. For my purposes, the sort -r will work.
Thanks,
TioTony