xfmt : V1.3=(W)= file record formatting.
format:xfmt [/options] filename [fieldspec ...]
options :
/D"delms" :additional input field delimiter.
default is " \t"(space and tab).
/L[n]x[str]:line selection string specification. n:column, x:S/E/I/X.
S: line selection Start from the line containing this string.
E: line selection End with the line containing this string.
I: select the line Including this string.
X: eXclude the line containing this string.
+: AND condition of previous condition.
I and X is checked sequencialy as specified.
assume full select if first is X. exclude all if start by I.
ex) /L8S"12:00:00" /L8E"13:00:00"
(line select start from the lines with "12:00:00"
at column 8 to the line with "13:00:00" at column 8)
/LX"Normal" /L20I"Overridden"
(exclude the line with "Normal" at col.1
except col.20 is "Overridden")
/L5I"RC" /L9+"Ok"
(select the lines with "RC" at col.5 and "Ok" at col.9)
/Ooutfile :output filename. default is stdout.
/Q[s][d] :quotation consideration. ignore delmiter in quotationn.
s:single quotation, d:double quotation. /Q means both.
/Rnn :insert (CR)LF for each nn byte(for file with no EOL id).
/S[R]"seps":output field seperator. default is " "(1 space).
R:replace all delimiter of input file by this parameter.
/Xoutfile2 :excluded line output filename. default is no output.
/Yx,/Nx :other flag option.
Na:no field alignment as default. Without Ys,copy write.
With Ys,output space compressed.
Nc:no confirmation msg when output file override.
Ys:select only the fields of fieldspec.
fieldspec: fieldno[-fieldno]][O][R|L|P][N|A][C][:col-spec]
col-spec: [X]{start-substr|[-]cols}[:{end-substr|[-]cols|Llength}]
start/end-substr: [T|E][-]{A|B}fldstr
fieldno:field-No separated by delimiter(default:space and tab). max=99.
O :OutOfRange,followings are one field as whole.
R :Right justify the field. Default unless /Na is specified.
L :Left justify the field.
P :align by decimal point.
N :search numeric field and right hsutify at the point.
A :reset once effect of N & C for following fields.
C :compress interfield spaces of all following to a space.
with N,compress until numeric field found.
ex) l 5r (Left justify except fieldNo 5)
1-5p (apply "P" for field 1 to 5 if decimal point numeric)
r l 4c (Right,Left,Left then compress all after fieldNo 4)
X :option to exclude sustring.
T|E :start/end position for the line with no fldstr. Top or End ?
For start-str,defaut is "e" with X(exclude substr) option,
else "t". For end-str,defaut is "e" for both with and w/o X.
[-]A|B :substring start/end at A(After) or B(Before) the fldstr.
"-" means backword string search.
fldstr :string to determin substring position.
Enclose by single quotation(') if it contains ":".
ex) 3:xb"time out"
(drop substring before "time out" if fieldNo 3 has it)
4:a'Time:':bElapsed
(pickup substring after "Time:" to before "Elapsed")
[-]cols:substring start/end column. "-" means cols from end.
ex) 3:3:5 (pickup col3-5 of field-No 3)
6:x-5:-2 (cut first 4 byte and last 1 byte of field-No6)
Llength:substring len. means up to end-of-field if missing.
ex) 3:3:L5 (pickup 5 byte from col3 of field-No 3)
(Note) substring position is for the string after aligned for P type.
w/o fieldspec param,all fields are put right aligned if no /Ys,/Na parm.
alignment specification only(without field-no) is effective on the field
correspond to the specification and followings upto end of line.
sample) xfmt /L5S"10:00:00" /L5E"11:59:59" /LIexcept /LXNullPo file1 r 5l
xfmt /Q /S"," /Na /Ys file2 5:x4 6:-3:L2 1 3:t-a?:4 7:b"x y":a"x z"
xfmt file3 nc:999:l1
Sample Execution.
**********************************************************************
14:39:09 ===>> cat inp1
2005/01/22 10:19 <DIR> .
2005/01/22 10:19 <DIR> ..
2007/05/18 17:23 80 @
2000/07/08 18:08 1,302 @0
2001/09/08 08:38 22,440 @1
2001/09/08 08:38 22,440 @2
2000/07/08 09:47 80 @3
2000/07/23 06:51 8,661 @@
2000/07/08 19:36 1,410 @@0
2001/08/30 12:55 521 @@1
(*** fields alignment-1:: l:Left justify up to next, 3:fieldNumber 3, r:Right justify upto end of line***)
14:39:44 ===>> xfmt inp1 l 3r
2005/01/22 10:19 <DIR> .
2005/01/22 10:19 <DIR> ..
2007/05/18 17:23 80 @
2000/07/08 18:08 1,302 @0
2001/09/08 08:38 22,440 @1
2001/09/08 08:38 22,440 @2
2000/07/08 09:47 80 @3
2000/07/23 06:51 8,661 @@
2000/07/08 19:36 1,410 @@0
2001/08/30 12:55 521 @@1
xfmt:V1.1(W): *** Done *** inp1 --> stdout , null ***
read:10, write:10, excluded:0, short-line:0
(*** fields alignment-2::***)
14:40:29 ===>> xfmt inp1 l 3r 4r
2005/01/22 10:19 <DIR> .
2005/01/22 10:19 <DIR> ..
2007/05/18 17:23 80 @
2000/07/08 18:08 1,302 @0
2001/09/08 08:38 22,440 @1
2001/09/08 08:38 22,440 @2
2000/07/08 09:47 80 @3
2000/07/23 06:51 8,661 @@
2000/07/08 19:36 1,410 @@0
2001/08/30 12:55 521 @@1
xfmt:V1.1(W): *** Done *** inp1 --> stdout , null ***
read:10, write:10, excluded:0, short-line:0
**********************************************************************
14:58:04 ===>> cat inp2
2005/01/22 10:19 <DIR> .
2005/01/22 10:19 <DIR> ..
2007/05/18 17:23 80 @
2000/07/08 18:08 1.302 @0
2001/09/08 08:38 22.440 @1
2001/09/08 08:38 22.440 @2
2000/07/08 09:47 80 @3
2000/07/23 06:51 8.661 @@
2000/07/08 19:36 1.410 @@0
2001/08/30 12:55 521 @@1
(*** fields alignment-3:: p:decimal point algnment from fieldNo-1 to end of line ***)
14:58:23 ===>> xfmt inp2 p
2005/01/22 10:19 <DIR> .
2005/01/22 10:19 <DIR> ..
2007/05/18 17:23 80 @
2000/07/08 18:08 1.302 @0
2001/09/08 08:38 22.440 @1
2001/09/08 08:38 22.440 @2
2000/07/08 09:47 80 @3
2000/07/23 06:51 8.661 @@
2000/07/08 19:36 1.410 @@0
2001/08/30 12:55 521 @@1
xfmt:V1.1(W): *** Done *** inp2 --> stdout , null ***
read:10, write:10, excluded:0, short-line:0
**********************************************************************
15:04:27 ===>> cat inp3
2005/01/22 10:19 <DIR> .
2005/01/22 10:19 <DIR> ..
2007/05/18 17:23 1 a 80 @
2000/07/08 18:08 2 a 1.302 @0
2001/09/08 A08:38 2 a 22.440 @1
2001/09/08 08:38 4 a 22.440 @2
2000/07/08 09:47B 5 a 80 @3
2000/07/23 06:51 99 a 8.661 @@
2000/07/08 19:36 9 a 1.410 @@0
2001/08/30 12:55 999 a 521 @@1
(*** fields alignment-4:: n:numeric field only ***)
15:05:13 ===>> xfmt inp3 n
2005/01/22 10:19 <DIR> .
2005/01/22 10:19 <DIR> ..
2007/05/18 17:23 1 a 80 @
2000/07/08 18:08 2 a 1.302 @0
2001/09/08 A08:38 2 a 22.440 @1
2001/09/08 08:38 4 a 22.440 @2
2000/07/08 09:47B 5 a 80 @3
2000/07/23 06:51 99 a 8.661 @@
2000/07/08 19:36 9 a 1.410 @@0
2001/08/30 12:55 999 a 521 @@1
xfmt:V1.1(W): *** Done *** inp3 --> stdout , null ***
read:10, write:10, excluded:0, short-line:0
(*** fields alignment-5:: c:compaction up to end of line***)
15:06:22 ===>> xfmt inp3 3c
2005/01/22 10:19 <DIR>
2005/01/22 10:19 <DIR> .
2007/05/18 17:23 1 a 80
2000/07/08 18:08 2 a 1.302 @
2001/09/08 A08:38 2 a 22.440 @
2001/09/08 08:38 4 a 22.440 @
2000/07/08 09:47B 5 a 80 @
2000/07/23 06:51 99 a 8.661 @
2000/07/08 19:36 9 a 1.410 @@
2001/08/30 12:55 999 a 521 @@
xfmt:V1.1(W): *** Done *** inp3 --> stdout , null ***
read:10, write:10, excluded:0, short-line:0
(*** fields aselection:: -Ys:seect specified field***)
16:08:28 ===>> xfmt inp3 /ys 2 3 5
10:19 <DIR>
10:19 <DIR>
17:23 1 80
18:08 2 1.302
A08:38 2 22.440
08:38 4 22.440
09:47B 5 80
06:51 99 8.661
19:36 9 1.410
12:55 999 521
xfmt:V1.1(W): *** Done *** inp3 --> stdout , null ***
read:10, write:10, excluded:0, short-line:2
**********************************************************************
16:50:30 ===>> cat inp4
NAME=angel AGE:60 f Addr-Stockholm
NAME=sky AGE:60 m Addr-Tokyo
NAME=erth AGE:600 f Addr-LosAngels
NAME=moon AGE:6000 m Addr-another world
(*** cut string :: 1l:left justify fieldNo1, a: pickup After string "Name=" of filedNo1 ***)
( 4l:a"Addr-" pickup After string "After-" of fieldNo4 then left justify ***)
16:50:35 ===>> xfmt inp4 r 1l:a"NAME=" 4l:a"Addr-"
angel AGE:60 f Stockholm
sky AGE:60 m Tokyo
erth AGE:600 f LosAngels
moon AGE:6000 m another world
xfmt:V1.1(W): *** Done *** inp4 --> stdout , null ***
read:4, write:4, excluded:0, short-line:0
(*** cut string :: 4l:a"-" :pickup After string "-" of filedNo4 ***)
23:13:10 ===>> xfmt x2 4l:a"-"
NAME=angel AGE:60 f Stockholm
NAME=sky AGE:60 m Tokyo
NAME=erth AGE:600 f LosAngels
NAME=moon AGE:6000 m another world
xfmt:V1.1(W): *** Done *** x2 --> stdout , null ***
read:4, write:4, excluded:0, short-line:0
(*** cut string :: 4l:xa"-" :cut After string "-" of filedNo4 ***)
23:13:29 ===>> xfmt x2 4l:xa"-"
NAME=angel AGE:60 f Addr-
NAME=sky AGE:60 m Addr-
NAME=erth AGE:600 f Addr-
NAME=moon AGE:6000 m Addr- world
xfmt:V1.1(W): *** Done *** x2 --> stdout , null ***
read:4, write:4, excluded:0, short-line:0
(*** field delimiter other than space:: /d"=-" delimiter is "=","-" and space ***)
17:01:24 ===>> xfmt inp4 /d"=-"
NAME= angel AGE:60 f Addr- Stockholm
NAME= sky AGE:60 m Addr- Tokyo
NAME= erth AGE:600 f Addr- LosAngels
NAME= moon AGE:6000 m Addr- another world
xfmt:V1.1(W): *** Done *** inp4 --> stdout , null ***
read:4, write:4, excluded:0, short-line:0
(*** replace delimiter:: /SR":": rep delm "=" and "-" by ":" ***)
17:01:38 ===>> xfmt inp4 /d"=-" /SR":"
NAME: angel AGE:60 f Addr: Stockholm
NAME: sky AGE:60 m Addr: Tokyo
NAME: erth AGE:600 f Addr: LosAngels
NAME:moon AGE:6000 m Addr:another world
xfmt:V1.1(W): *** Done *** inp4 --> stdout , null ***
read:4, write:4, excluded:0, short-line:0
(*** replace delimiter:: /SR" ": rep delm "=" and "-" by " " ***)
17:02:10 ===>> xfmt inp4 /d"=-" /SR" "
NAME angel AGE:60 f Addr Stockholm
NAME sky AGE:60 m Addr Tokyo
NAME erth AGE:600 f Addr LosAngels
NAME moon AGE:6000 m Addr another world
xfmt:V1.1(W): *** Done *** inp4 --> stdout , null ***
read:4, write:4, excluded:0, short-line:0
(*** line selection:: /lsangel: selection start from the line having string "angel" ***)
( /leLos : selection end at the line having string "Los" ***)
17:04:36 ===>> xfmt inp4 /lsangel /leLos
NAME=angel AGE:60 f Addr-Stockholm
NAME=sky AGE:60 m Addr-Tokyo
NAME=erth AGE:600 f Addr-LosAngels
xfmt:V1.1(W): *** Done *** inp4 --> stdout , null ***
read:4, write:3, excluded:1, short-line:0
(*** line selection:: /lxsky : do not select the line having string "sky" ***)
17:05:43 ===>> xfmt inp4 /lsangel /leLos /lxsky
NAME=angel AGE:60 f Addr-Stockholm
NAME=erth AGE:600 f Addr-LosAngels
xfmt:V1.1(W): *** Done *** inp4 --> stdout , null ***
read:4, write:2, excluded:2, short-line:0
(*** line selection:: /lxm : do not select the line having string "m" ***)
17:09:31 ===>> xfmt inp4 /lxm
NAME=erth AGE:600 f Addr-LosAngels
xfmt:V1.1(W): *** Done *** inp4 --> stdout , null ***
read:4, write:1, excluded:3, short-line:0
**********************************************************************
16:57:24 ===>> cat inp5
'NAME angel' AGE:60 f Addr Stockholm 1
'NAME sky' AGE:60 m Addr Tokyo 2
'NAME erth' AGE:600 f Addr "Los Angels" 3
'NAME moon' AGE:6000 m Addr "another world" 4
(*** quatation :: ignored as default ***)
16:57:28 ===>> xfmt inp5 l
'NAME angel' AGE:60 f Addr Stockholm 1
'NAME sky' AGE:60 m Addr Tokyo 2
'NAME erth' AGE:600 f Addr "Los Angels" 3
'NAME moon' AGE:6000 m Addr "another world" 4
xfmt:V1.1(W): *** Done *** inp5 --> stdout , null ***
read:4, write:4, excluded:0, short-line:0
(*** quatation :: /q: consideration single and double quotation ***)
16:57:37 ===>> xfmt inp5 l /q
'NAME angel' AGE:60 f Addr Stockholm 1
'NAME sky' AGE:60 m Addr Tokyo 2
'NAME erth' AGE:600 f Addr "Los Angels" 3
'NAME moon' AGE:6000 m Addr "another world" 4
xfmt:V1.1(W): *** Done *** inp5 --> stdout , null ***
read:4, write:4, excluded:0, short-line:0