exec

Commands ››
Parent Previous Next

The exec command is used to execute an external command, using the CSV input data as command parameters. This command is intended to be used when the built-in features of CSVfix do not suffice to solve a problem.


See also: eval, call


Flag

Req'd?

Description

-c cmd

Yes

Specifies the command to be executed together with the parameters to use. Parameters are specified by place-holders in the format %1, %2 etc. which indicate the first, second (and so on) CSV fields. The command is executed once for each CSV input record. For example:


-c "echo %1 %4"


specifies that the echo command should be called for each CSV input record, with the values in CSV input fields 1 and 4 as parameters.


If you need a literal % character in the command, use a %% pair.

-r

No

By default, the command's output is parsed as CSV and the resulting column(s) are appended to the input row. Using the -r flag causes the command's output to replace all the input record data and to be treated as plain text


The following example transliterates all lower-case vowels in the surname & forename fields of names.csv into an upper-case X character by using the UN*X tr command:


csvfix exec -c 'echo %1 %2 | tr aeiou X' data/names.csv


which produces:


"Charles","Dickens","M","ChXrlXs DXckXns"

"Jane","Austen","F","JXnX AXstXn"

"Herman","Melville","M","HXrmXn MXlvXllX"

"Flann","O'Brien","M","FlXnn O'BrXXn"

"George","Elliot","F","GXXrgX EllXXt"

"Virginia","Woolf","F","VXrgXnXX WXXlf"

"Oscar","Wilde","M","OscXr WXldX"


Created with the Personal Edition of HelpNDoc: Create iPhone web-based documentation