###### simple example ######### $ echo -e "a b c d e\nf g h i j\nk l m n o\np q r s" | awk '{ lines[i++]=$(NF-1) } END{ print lines[NR-3] }' i ############################### ###### mencoder output ######## [robert@phebehouse src] $ mencoder 2.mpg -quiet -ovc copy -oac pcm -o /dev/null 2>/dev/null MEncoder dev-SVN-rUNKNOWN-4.1.3 (C) 2000-2007 MPlayer Team CPU: AMD Athlon(tm) XP 2900+ (Family: 6, Model: 10, Stepping: 0) CPUflags: Type: 6 MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 0 Compiled with runtime CPU detection. success: format: 0 data: 0x0 - 0x355e800 MPEG-PS file format detected. VIDEO: MPEG2 720x480 (aspect 2) 29.970 fps 9000.0 kbps (1125.0 kbyte/s) [V] filefmt:2 fourcc:0x10000002 size:720x480 fps:29.97 ftime:=0.0334 ========================================================================== Opening audio decoder: [liba52] AC3 decoding with liba52 AUDIO: 48000 Hz, 2 ch, s16le, 448.0 kbit/29.17% (ratio: 56000->192000) Selected audio codec: [a52] afm: liba52 (AC3-liba52) ========================================================================== videocodec: framecopy (720x480 24bpp fourcc=10000002) a52: CRC check failed! Writing header... ODML: Aspect information not (yet?) available or unspecified, not writing vprp header. Writing header... ODML: Aspect information not (yet?) available or unspecified, not writing vprp header. Writing index... Writing header... ODML: Aspect information not (yet?) available or unspecified, not writing vprp header. Video stream: 2563.437 kbit/s (320429 B/s) size: 46337683 bytes 144.611 secs 4336 frames Audio stream: 1536.000 kbit/s (192000 B/s) size: 27771904 bytes 144.645 secs ######################################## [robert@phebehouse src] $ mencoder 2.mpg -quiet -ovc copy -oac pcm -o /dev/null 2>/dev/null | awk '{ lines[i++]=$(NF-1) } END{ print lines[NR-3] }' awk: (FILENAME=- FNR=23) fatal: attempt to access field -1 ########################################