Cut command, no input delim, output delim not working

Hello,

I'm using cygwin on my Windows 7 machine.

From the man pages of cut:
--output-delimiter=STRING
use STRING as the output delimiter the default is to use the input delimiter

I tried the following commands and got the error messages:

$ cut -c1-10,20-30 -d --output-delimiter=| filename
cut: the delimiter must be a single character
Try `cut --help' for more information.
-bash: filename: command not found

$ cut -c1-10,20-30 -d --output-delimiter="|" filename
cut: the delimiter must be a single character
Try `cut --help' for more information.

$ cut -c1-10,20-30 -d --output-delimiter='|' filename
cut: the delimiter must be a single character
Try `cut --help' for more information.

$ cut -c1-10,20-30 -d --output-delimiter'|' filename
cut: the delimiter must be a single character
Try `cut --help' for more information.

$ cut -c1-10,20-30 -d --output-delimiter| filename
cut: the delimiter must be a single character
Try `cut --help' for more information.
-bash: filename: command not found

$ cut -c1-10,20-30 -d --output-delimiter"|" filename
cut: the delimiter must be a single character
Try `cut --help' for more information.

Is it possible that you cannot specify a output delim if you don't specify an input delim? What if there is no input delim in the file...such as a fixed length file and you want an output delim?

Can anyone shed some light on this??? :frowning:
Thanks in advance!

$ cut -c1-10,20-30 -d --output-delimiter=| filename
cut: the delimiter must be a single character

That error is because of -d or --delimiter

Please use code tags for code and output,

```text
stuff
```

With cut -b... and cut -c... the input delimiter is never used anyway. And, since you are creating a single sequence of characters (not fields), I'm not sure you can specify an output field delimiter either. The version of cut I use doesn't have an --output-delimiter option.
You could try:

cut -c1-10,20-30 --output-delimiter="|" filename

but you'll probably need something more like:

awk '{print substr($0, 1, 10) "|" substr($0, 20, 11)}' filename

Aia, I tried!

$ cut -c1-2,4-5 -d --output-delimiter=| t.txt
cut: the delimiter must be a single character
Try `cut --help' for more information.
-bash: t.txt: command not found

Don Cragun, I tried!
$ cut -c1-2,4-5 -d --output-delimiter="|" t.txt
cut: the delimiter must be a single character
Try `cut --help' for more information.

I'm wondering if it is the cygwin environment running on Windows 7!!

Don, the awk command worked nicely!! Much thanks to you both!!

To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags

```text
 and 
```

by hand.)

Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums

What is the input delimiter you want, required after '-d'?

$ cut -c1-2,4-5 -d ' ' --output-delimiter="|" t.txt
$ cut -c1-2,4-5 -d --output-delimiter=| t.txt
cut: the delimiter must be a single character
Try `cut --help' for more information.
-bash: t.txt: command not found

If you use -d you must give it a char that represent the input delimiter, after it. You are not giving it anything. Otherwise, it takes "--output-delimiter=" as the parameter, which obviously is incorrect, it complains about it, and pipes it to t.txt as it were a program that accepts data, thus the -bash: t.txt: command not found

edit: Nevermind. Don already posted the right cut command in post #4.

Please look closely at what I suggested! There was no -d option in what I suggested and there were double quotes around the | . I'm glad the awk command worked, but you might also be able to use:

cut -c1-2,4-5 --output-delimiter="|" t.txt

Hi Don,
I guess I've trying so many combinations of the command I automatically typed in the -d.

Your suggestion worked! Much much thanks!
+Kojac

---------- Post updated at 06:10 PM ---------- Previous update was at 06:02 PM ----------

Hi DG

I got it resolved, thanks for responding.
There was no input delim needed, (fixed length record) only wanted an output delim and the syntax got the better of me!