How do you use two delimiters in cut command?

How do you use two delimiters in cut command?

3 Answers

  1. awk with multiple delimiters echo Sample_0000860156-001-out_20150224150524.xml.gz | awk -F ‘[_-]’ ‘{print $2″-“$3}’
  2. GNU grep echo Sample_0000860156-001-out_20150224150524.xml.gz | grep -oP ‘_\K.*(?=-)’
  3. sed echo Sample_0000860156-001-out_20150224150524.xml.gz | sed ‘s/.*_\([0-9]*-[0-9]*\)-.*/\1/’

What is space delimited list?

A space-delimited list is a kind of list (not a kind of space). It is a list which is delimited by spaces. The items x, y, and z have spaces between them: these spaces are the delimiters in the list. Likewise the list “x,y,z” is a comma-delimited list (it is in comma-delimited format).

How to use space as a delimiter with the cut command?

I want to use space as a delimiter with the cut command. What syntax can I use for this? Where 2 is the field number of the space-delimited field you want. (a) whether cut itself requires the delimiter (space, in this case) passed to the -d option to be a separate argument or whether it’s acceptable to append it directly to -d.

How to split text by space / comma / delimiter?

1. Select the range you will split text strings (in our case we select the range A1:A9 ), and click Kutools > Text > Split Cells. 2. In the opening Split Cells dialog box, please check the Split to Rows option or Split to Columns options as you need in the Type section, next specify a delimiter in the Specify a separator section,

When to use space as a delimiter in AWK?

Usually if you use space as delimiter, you want to treat multiple spaces as one, because you parse the output of a command aligning some columns with spaces. In this case a single cut command is not sufficient, and you need to use: Thanks for the awk example usage, just what I needed.

Can you break columns on whitespace in Bash?

Breaking on whitespace is the default, but you can also break on multi-char regexes, alternative regexes, etc. so the above command would break columns on whitespace and extract the (0-based) cols 6 2 8 7 in that order. As a sed expression, the capture group needs to be escaped, i.e. \\ ( and \\).