Blog

Fresh command shell:cut

Geschrieben 2018. Versionen und Details können veraltet sein.

Just added the command 'shell:cut' to allow splitting of lines. The command is more flexible than the original shell command and allows splitting by regular expressions.
This is the option list:
  • -r Replace regex
  • -e Regular expression
  • -d Separate parts by this regex
  • -t Trim every single part
  • -f Fields expression
  • -j Glue between fields
  • -p Positions
Field expressions are a comma separated list of fields or field ranges. The first field is zero '0'.
Examples:
bundle:list|cut -d \\\| -t -j ' ' -f 1,3,2
Active 80 0.0.0
...
bundle:list|cut -d \\\| -t -j ' ' -f 1-,0
Active 80 1.4 Commons DBCP 71
...
bundle:list|cut -d \\\| -t -j ' ' -f 1,abc,2
Active abc 80
...
The option -p is followed by a list of ranges in the line.
Examples:
bundle:list|cut -j '&' -p 10-20,1-10,abc
ve |  80 |&69 | Acti&abc
...
A position definition can't be out of bounds. In the worst case it will be ignored. An empty line - without written fields - will be ignored.
The options -e and -r must be defined together and change the line content before processing the split mechanism.