I have a table in which each entry looks something like,

coagulation factor VIII-associated 1 /// coagulation factor VIII-associated 2 /// coagulation factor VIII-associated 3

I would like to use cut -d/// -f2 myfile.txt, but I'm getting an error:

cut: bad delimiter

Same case when I use single quotes or double quotes around the delimiter:

cut -d'///' -f2 myfile.txt

cut -d"///" -f2 myfile.txt

Do I have to escape the slash somehow? If so, what is the escape character for cut? Documentation doesn't seem to have that information, and I tried \.


3 Answers 3


If the delimiter is anything other than one fixed character, then cut is the wrong tool.

Use awk instead.

Consider this test file which has three fields:

$ cat file

To print the second field and only the second field:

$ awk -F/// '{print $2}' file
  • To add to this: Nothing wrong with asking here, but you should generally check the man page for the tool you are using as well. cut's manual does specify it only works with single-character delimiters.
    – Wildcard
    Jun 14, 2016 at 1:23

The other answers are all right but there's also the possibility of replacing your current delimiter in order to use cut as you wanted such as:

sed "s/\/\/\//\//g" myfile.txt | cut -d/ -f2
  • 1
    using a different delimiter for sed (e.g. sed 's=///=/=g') is easier to read because it avoids Leaning Toothpick Syndrome
    – cas
    Jun 14, 2016 at 8:57
  • That just shows there are always many ways to do the same thing. Jun 14, 2016 at 15:06

A delimiter with cut is always a single character, so you can't specify "///" as a delimiter.

Instead, you'd use "/" as delimiter and count the extra fields:

cut -d/ -f4 myfile.txt

(fields 2 and 3 are the empty fields between the slashes in "///").

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .