0

The following sed returns (...| od -c) without ...|cut -d "\n" -f

0000000 1 9 2 \n 2 5 0 \n 0000010 

Pseudocode

# http://unix.stackexchange.com/a/290407/16920 sed -n -f - /usr/share/X11/xkb/symbols/us <<END_SED | cut -d "\n" -f1 /xkb_symbols "dvorak" {/,/^};/{ /xkb_symbols "dvorak" {/= /^};/= } END_SED 

but blank output.

System: Ubuntu 16.04 64 bit
Hardware: Macbook Air 2013-mid
Sed: 4.2.2
Cut, od: Coreutils 8.25

4
  • what's wrong with @Kusalananda 's answer ? Commented Jun 19, 2016 at 7:43
  • 1
    I updated my answer to that question in such a way that the output is read into an array variable. The two values are then easily accessed through array index 0 and 1. Commented Jun 19, 2016 at 7:47
  • If you want the first line of output use ... | head -n 1 Commented Jun 19, 2016 at 9:09
  • @steeldriver Yes, it works, but I want the second line. Commented Jun 19, 2016 at 9:27

1 Answer 1

2

The cut utility "cuts" one or several columns out of its input. Like many other Unix utilities, cut is a stream-based line-by-line reader that applies its processing to each line of input and then contiues with the next line.

You can not use \n as the delimiter for cut since that is what it expects separate the lines.

A roundabout way of creating two columns for cut to work with would be to use paste. The paste utility also reads it input line-by-line, but it buffers and outputs it into tab-delimited columns according to the specification that you give it.

In this case:

$ mycommand | paste - - 192 250 

Then with cut added:

$ mycommand | paste - - | cut -f1 192 
1

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.