Job Name Last Start Last End ST Run Pri/Xit
____________________________ ________________ ________________ __ _______ ___
35111_AAA ----- ----- OI 0/0
35111_BBB ----- ----- IN 0/0
35111_CCC 09/01/2009 08:57 09/01/2009 08:57 FA 55556015/1 1
35111_DDD
----- ----- OI 0/0
35111_EEE
03/20/2008 11:27 03/20/2008 11:40 SU 38917388/2
35111_FFF ----- ----- OI 0/0
35111_GGG ----- ----- OI 0/0
I want data in following format
AAA 35111_AAA ----- ----- OI 0/0
AAA 35111_BBB ----- ----- IN 0/0
AAA 35111_CCC 09/01/2009 08:57 09/01/2009 08:57 FA 55556015/1 1
AAA 35111_DDD ----- ----- OI 0/0
AAA 35111_EEE 03/20/2008 11:27 03/20/2008 11:40 SU 38917388/2
AAA 35111_FFF ----- ----- OI 0/0
AAA 35111_GGG ----- -----
awk 'END { print r }
$1 ~ /_/ && r { print r }
NR > 3 && NF {
$1 = $1
r = (split($1, t, "_") > 1 ? t[2] : r) FS $0
}' infile
Use gawk, nawk or /usr/xpg4/bin/awk on Solaris.
No sort/unique for now, just trying to format the text as of your last post.
P.S. Squeezed the white space characters, not sure if you want that, though ...
---------- Post updated at 05:25 PM ---------- Previous update was at 05:16 PM ----------
Oops, just saw you have only an "AAA" in your first column, is that correct?