Skip navigation.
Home

Reply to comment

Using "\n" as delimiter of cut

You cannot specify "\n" directly with Bash:

$ brctl show | cut -d "\n" -f 2 | cut -f 1
cut: the delimiter must be a single character
Try `cut --help' for more information.

The correct syntax is:

$ brctl show | cut -d "
> " -f 2 | cut -f 1
testbr

But "\n" can be used directly in system call of other programming language rather than Bash. Eg.

# python
Python 2.4.3 (#1, Jun  6 2007, 15:09:38) 
[GCC 4.1.1 20070105 (Red Hat 4.1.1-52)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> status = os.system('brctl show | cut -d "\n" -f 2 | cut -f 1')
testbr
>>> import commands
>>> print commands.getoutput('brctl show | cut -d "\n" -f 2 | cut -f 1')
testbr

Reply

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <h1>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
13 + 6 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.