Question

I'm trying to pipe data into "cut" to, say, cut away the first column of text. This works

$ cat test.txt | cut -d\  -f2-

Reading from stdin also works:

$ cut -d\  -f2- -
? doc/html/analysis.html
? doc/html/classxytree-members.html
<CTRL+D>

However, as soon as a pipe is involved, it doesn't accept my <CTRL+D> anymore, and I can't signal "end of file":

$ cut -d\  -f2- - | xargs echo

Update: This is apparently a bug in an old version of bash (3.00.15). It does work in more recent versions (tried 4.0.33 and 3.2.25). It would be nice to have some workaround, though, since I can't easily upgrade.


Background: I've got a script/oneliner that gives me a condensed output of cvs status (I know, CVS...) in the form

? filename

e.g. for a file not committed yet. I'd like to be able to copy+paste parts of the output from that command and use this as an input to another command, that adds these files to cvs. Say:

$ cut -d\  -f2- | xargs cvs add
<paste lines>
<CTRL-D>        # <-- doesn't work

Ideas?

Was it helpful?

Solution

have you tried

$ cat | cut -d\  -f2- | xargs cvs add
<paste lines>
<CTRL-D>        # <-- doesn't work

OTHER TIPS

Your examples work fine for me. What shell are you using? What utilities?

One thing that sometimes trips people up is that Ctrl-D only works if it's the first character in the line. If you copy and paste, you might sometimes accidentally have whitespace as the first character of the line, or no newline at the end of the pasted block, in which case Ctrl-D won't work. Just hit return and then try Ctrl-D again and see if that fixes your problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top