Sponsored Content
Top Forums UNIX for Dummies Questions & Answers how to sort and arrange an output Post 302145094 by Perderabo on Monday 12th of November 2007 08:39:11 PM
Old 11-12-2007
A ksh solution:
Code:
$ cat listr
#! /usr/bin/ksh

LIST="DETOT
MANOA
DETOM
DETOA
MANOT
SEAOT"

c1=0
c2=0
c3=0
for word in $LIST ; do
        suffix=${word#${word%??}}
        case $suffix in
        OT) list1[c1]=$word
                ((c1=c1+1))
                ;;
        OA) list2[c2]=$word
                ((c2=c2+1))
                ;;
        OM) list3[c3]=$word
                ((c3=c3+1))
                ;;
        *)  echo $word does not have a standard suffix
                ;;
        esac
done
        set -A list1 -s ${list1[*]}
        set -A list2 -s ${list2[*]}
        set -A list3 -s ${list3[*]}
        set -A counts -s ${#list1[*]} ${#list2[*]} ${#list3[*]}
        max=${counts[((${#counts[*]}-1))]}
n=0
typeset -L12 item1 item2 item3
while ((n<max)) ; do
        item1=${list1[n]}
        item2=${list2[n]}
        item3=${list3[n]}
        echo "$item1 $item2 $item3"
        ((n=n+1))
done
exit 0
$
$
$ ./listr
DETOT        DETOA        DETOM
MANOT        MANOA
SEAOT
$

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Sort - only one field appears in output?

I'm running against a file with 1008 records like this, all beginning '4760 Slave': 4760 Slave,7,3607 ,GL ,200605,11320024 , ,GBP ,X00033 ,AI80190 ... (1 Reply)
Discussion started by: miwinter
1 Replies

2. Shell Programming and Scripting

sort output

this one is a bit tricky: host16 /etc/passwd changed Thu Jan 3 16:39:48 host3 /etc/group changed Thu Jan 3 16:39:48 host2 /etc/services changed Thu Jan 3 16:39:48 host10 /etc/group changed Thu Jan 10 09:59:01 host11 /etc/group changed Thu Jan 3 18:55:38 host17 /etc/group changed Thu Jan... (9 Replies)
Discussion started by: funksen
9 Replies

3. UNIX for Dummies Questions & Answers

Sort fdupes output by size

Hi I have a file that is a fdupes output. I'd like to sort the duplicated file by size. The format file is the following: 5996544 bytes each: /path1/to/file1.jpg /path2/to/file1.jpg /pathx/to/file1.jpg ... random number of lines /path999/to/file1.jpg 591910 bytes each:... (2 Replies)
Discussion started by: AdminLew
2 Replies

4. Shell Programming and Scripting

Arrange output based on rows into columns

Hi All, I would like to ask help on how can i achieve below output. Inputfile: Oct11,apa1-daily,01:25:01 Oct11,apa2-daily,01:45:23 Oct12,apa1-daily,02:30:11 Oct12,apa2-daily,01:55:01 Oct13,apa1-off,01:43:34 Oct13,apa2-off,01:22:04 Desired output: Clients ... (3 Replies)
Discussion started by: mars101
3 Replies

5. Shell Programming and Scripting

Sort output is different with Corn

Hi, I am sorting a file, but getting different output with crontab. input file-file z Z x X y Y when I sort manually sort file x X y Y z Z (4 Replies)
Discussion started by: suresh3566
4 Replies

6. Shell Programming and Scripting

Sort and output to different files

Hi all! I have a comma delimited file and I'm sorting it based on fields 6, 8 and 10. The following does the job: sort -t, -nk6,10 unsorted.txt -o sorted.txt What I need to do now is to write every row containing same values on fields 6, 8 and 10 to a different file. Any ideas on how to do... (2 Replies)
Discussion started by: Tr0cken
2 Replies

7. Shell Programming and Scripting

sort ps output in seconds

Now I van sort in hour-minute-second. I need in seconds ps -eo pid,etime,args --sort=start_time | grep bash Sample Output 15064 03:23 -bash I need in 03:23 in seconds (1 Reply)
Discussion started by: anil510
1 Replies

8. Shell Programming and Scripting

Need to sort an output

with a command i get a long list (example) and the entrys are intended. DName=AAAAA DName=AAAAA lba=838,860,800 label=ftw_1 DName=BBBBB DName=BBBBB lba=838,860,800 label=ftw_2 DName=CCCCC ... (3 Replies)
Discussion started by: Serano
3 Replies

9. Linux

Arrange output of a command

Hi, I am using a command :- ps -auxwww 2> /dev/null | awk 'match ($0, GIN:*/) {print substr($0, RSTART+3, RLENGTH-3)}' | sort | grep -v -F 'which gives output as 3 aruau 5 asun 4 cgan Now I need a command which gives me something like this :- 3 aruau 5 asun 4 cgan... (2 Replies)
Discussion started by: Raj999
2 Replies

10. UNIX for Beginners Questions & Answers

Any way to sort ps output based on STIME?

Hi, This is one of the thing that am looking for when I post the question on the ps wrapper. It has since been closed as it has taken me too long to post an example. I have replaced some of the original content of the ps output. uname -a = SunOS <hostname> 5.11 11.3 sun4v sparc sun4v ... (1 Reply)
Discussion started by: newbie_01
1 Replies
zcons(7D)							      Devices								 zcons(7D)

NAME
zcons - Zone console device driver DESCRIPTION
The zcons character driver exports the console for system zones. The driver is comprised of two "sides:" a master side with which applica- tions in the global zone communicate, and a slave side, which receives I/O from the master side. The slave side is available in the global zones. Applications must not depend on the location of /dev or /devices entries exported by zcons. Inside a zone, the zcons slave side is fronted by /dev/console and other console-related symbolic links, which are used by applications that expect to write to the system console. The zcons driver is Sun Private, and may change in future releases. FILES
/dev/zcons/<zonename>/masterconsole Global zone master side console for zone <zonename>. /dev/zcons/<zonename>/slaveconsole Global zone slave side console for zone <zonename>. /dev/zconsole Non-global zone console (slave side). ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ | Interface Stability |Sun Private | +-----------------------------+-----------------------------+ SEE ALSO
zoneadm(1M), zonecfg(1M), attributes(5), zones(5) SunOS 5.11 24 Aug 2003 zcons(7D)
All times are GMT -4. The time now is 08:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy