|
|
Whitespace in SED
I thought that \s was for whitespace, but the following does not seem to
work. What am I missing?
s/^ \*\s*defin/ * Defin/I
I'm trying to fix the following comment block in some code. I want to force
two spaces between the asterisk and the initial "d", as well as convert the
"d" to uppercase. The spacing could be a combination of spaces or tabs (ie.
whitespace). The word "defining" could also be "define".
* defining buffer lengths
|
|
0
|
|
|
|
Reply
|
fmankal (2)
|
1/8/2004 6:42:04 PM |
|
frank wrote:
> I thought that \s was for whitespace, but the following does not seem to
> work. What am I missing?
The sed NG perhaps ;-) ?
> s/^ \*\s*defin/ * Defin/I
>
> I'm trying to fix the following comment block in some code. I want to force
> two spaces between the asterisk and the initial "d", as well as convert the
> "d" to uppercase. The spacing could be a combination of spaces or tabs (ie.
> whitespace). The word "defining" could also be "define".
>
> * defining buffer lengths
>
This will work:
sed 's/^ \*[ ]*[dD]efin/ * Defin/'
where there's a single blank followed by a single tab within the first
square brackets. For general white-space, look at the [:space:]
construct in GNU sed.
Ed.
|
|
0
|
|
|
|
Reply
|
Ed
|
1/8/2004 7:02:26 PM
|
|
frank wrote:
> I thought that \s was for whitespace, but the following does not seem to
> work. What am I missing?
>
> s/^ \*\s*defin/ * Defin/I
>
> I'm trying to fix the following comment block in some code. I want to force
> two spaces between the asterisk and the initial "d", as well as convert the
> "d" to uppercase. The spacing could be a combination of spaces or tabs (ie.
> whitespace). The word "defining" could also be "define".
>
> * defining buffer lengths
>
sed doesn't understand the \(letter) codes in regular expressions.
Use perl instead.
Chris Mattern
|
|
0
|
|
|
|
Reply
|
Chris
|
1/8/2004 8:35:07 PM
|
|
|
2 Replies
138 Views
(page loaded in 0.04 seconds)
Similiar Articles: sed: how to remove all duplicated white lines? - comp.unix.shell ...Hi there, i'd like to write a script that removes duplicate white lines whith sed, but couldn't find an apropriate script on the net. Can anyone po... Removing trailing blank lines - comp.lang.awksed 's/ *$//' -- William Park, Open Geometry Consulting, <opengeometry@yahoo.ca ... If blank lines may contain white space characters you may use NF { for ( ; n; n ... Space and TAB under HP UX 11 - comp.sys.hp.hpuxBut sed -e 's/^[ \t]*//;' filename is not working. \t will not be recognized. ... use "g" to kill all spaces, not just the first perl's "\s" means whitespace, "\S ... Using AWK...I need to print from column 4 to end - comp.lang.awk ...... Now I need to print from column 4 to end. > If you want to preserve white-space in the ... sed 's/^...//' > I thought by "column" the OP meant "field" rather than ... GNU Make: replace spaces with commas - comp.unix.programmer ...I can't figure out how to do this using Make-internal string commands ... sed ... ... GCC, the GNU Compiler Collection - GNU ..... sometimes outputs extra white space to avoid ... Simple XML processing in AWK - comp.lang.awkThere is a generalized, simple way to do it that's white space independent. ... format, or you have very specific requirements, imho in general using awk (or sed ... sed queation - remove all characters after a hyphen - comp.unix ...sed Removing whitespace around certain character - Stack Overflow... best way to remove whitespace only around certain character. Let's say a dash ... how to merge multiple lines into one line - comp.lang.awk ...... Tom Fred Jim Bob Dude Nerd I haven't got a clue how to accomplish it. Would sed ... using the default field separator (a space) so every sequences of contiguous white space ... How do I replace spaces with dash in a date ? - comp.lang.awk ...sed '/\.MP3$/s/\([0-9]\) \([0-9]\)/\1-\2/g' 2. sed 's/\([0-9]\+\) \([0-9 ... Handling Whitespace in Java DOM - comp.lang.java.programmer ..... comp.soft-sys.matlab ... split bash variable by semicolon - comp.lang.awkConsider a bash script where: header=$(head -1 $CAMINHO/$FICHEIRO | sed -e 's ... programming | Ask MetaFilter using bash, i need to split a variable in two, on whitespace ... sed to remove all whitespace from a line - Super UserI am wanting to use sed to remove all space characters from a text file. At present I am using this: sed 's/ //' test.txt > test2.txt This works in the sense that it ... sed tip: Remove / Delete All Leading Blank Spaces / Tabs ...Use sed command to delete / remove BOTH leading and trailing whitespace from each line including blank lines from a text file. 7/8/2012 8:23:01 AM
|
|
|
|
|
|
|
|
|