Fresh command shell:cut

Just added the command ‘shell:cut’ to allow splitting of lines. The command is more flexible as the original shell command and allows spliting by regular expressions.

This is the option list:

  • -r Replace regex
  • -e Regular expression
  • -d Seperate 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 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
...

Every positions definition can’t be out of boundls. 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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s