f



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
fmankal (2)
1/8/2004 6:42:04 PM
comp.lang.awk 3418 articles. 0 followers. Post Follow

2 Replies
588 Views

Similar Articles

[PageSpeed] 24


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
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
Chris
1/8/2004 8:35:07 PM
Reply:

Similar Artilces:

SED or AWK (AIX sed or awk!) script help
Hello all. I have a big file that I need to delete a number of lines out of. I want to read the values that will determine deletion out of another file, because there are multiple. Can someone post an example of a sed or awk script to do this? (sumGirl) wrote: > Hello all. I have a big file that I need to delete a number of lines > out of. I want to read the values that will determine deletion out of > another file, because there are multiple. > > Can someone post an example of a sed or awk script to do this? Have you tried this? grep -vf smallfile bigfile > newfile No...

AWK or sed ?
Hi There, I need to do a couple of substitutions within several html files in one single directory. The string: http://www.autism.au/%7Ebanner/dunes/nice_place/ must be replaced by: .../../../../ Does it need to be done with AWK or could sed do it? How to do it? Thanks! In article <1148311259.505147.224670@j73g2000cwa.googlegroups.com>, <mikeomike@gmail.com> wrote: >Hi There, > >I need to do a couple of substitutions within several html files in one >single directory. The string: > >http://www.autism.au/%7Ebanner/dunes/nice_place/ > >must be replace...

Awk or Sed ?
Greetings, What is the best way to do the following: I have a text file and want lines between regular expressions 'hat wear' and 'foot wear', but not including these lines. With the lines returned I'd like to add a '#'in front of them. Awk or sed ? I do not wish to use Perl for this -- should be sed or awk. I am thinking something like: sed '/^hat wear/,/^foot wear/' inputfile but I want to add a '#' to the lines between 'hat wear' and 'foot wear' too. Regards, Patricia On Fri, 7 Aug 2009 20:42:10 -0700 (PDT), Patricia Moor...

sed and awk
I have a question about when to use sed or awk, and their merits and defects. Now, given a cpp file, which has two form of comments: the line start with '//' and the linexs between '/*' and '*/' I want to get how many lines the comments are in the file. Of course, I can use sed as following: sed -n '/\/\*/,/\*\//p;/\/\//p' to output all the commets. But if I want to output the comments only, how to do? (this is not the main question,hehe) Now, I want to change a method, still use sed, but this time I want to do it another way: for the situation '//'...

sed awk
Hi i have a question on stripping a string out of a file. I never did anything with sed or awk. I was trying and couldn't really figure it out. My problem is as follows: I have a file e.g. <h3> 1.1 Hypertext </h3> <p> Hypertext has been defined as "an approach to information management in which data is stored in a network of nodes connected by ............ </p> I want to strip the 1.1. part after <h3>. Actually it is a more general problem i have a lot of files with a heading and a number after it. The only thi...

awk or sed??
Hi all I would like to know a awk or sed command that I will be able to keep a word from a file text exemple: the informations are wrote line by line dominique.dagenais christian.belzil alain.theroux ...... ...... which command will be able to extrac only de third line thank you this will print the third line of your file. awk ' NR == 3 { print $3 } ' or .... you can use your own counter to print every third line. Antonio Dell'elce "Antonio Dell'elce" <antonio.dellelce@gmail.com> wrote: [...] > awk ' NR == 3 { print $3 } ' ...

sed and awk
I don't know sed awk beyond very basic (substitution in sed, printing a column in awk), but was wondering if their matching mechanism has the equivalents to shell's ${var%%pattern} ${var%pattern} ${var#pattern} ${var##pattern} And by default, I believe sed and awk match the "longest" possible match, usually from left, but from right if $ anchor is used. 2012-03-08 20:07:15 -0800, Lax: > I don't know sed awk beyond very basic (substitution in sed, printing > a column in awk), but was wondering if their matching mechanism has > the equivalents to shell's >...

Sed, Awk, or both?
I need a script to automatically modify PostScript files. The PostScript file has patterns like following: .... TR12 setfont (Page 1 of 4 ) 2 0 12 515 755 st 0 1 550 539 575 514 box ( ) 0 1 12 552 524.5 st 1 5 0 537 526 tr 1 2 180 161 324 sq <--- Pattern (1) 1 2 90 71 330 tr <--- Pattern (1) 1 2 180 196 337 tr <--- Pattern (1) 454 320 446 320 dl .... TR12 setfont (Page 2 of 4 ) 2 0 12 515 755 st 1 5 0 161 324 tr <--- Pattern (2) 1 5 0 71 330 tr <--- Pattern (2) 1 5 0 196 337 tr ...

sed or awk?
I have a ridiculus ammount of files that needs to be sliced, here's a sample Some title of a source Author Source Publisher 2002 serial number Location I need to split this into Sometitle of a source Author Source Publisher 2002 serial number Location It would be easy if they only had one word text, however the title, author and source publisher have several text. How would I implement this? I thought about just getting the first line for the title, get the author and detect 5 spaces and get the source publisher and look for the white space between source publishe...

sed or awk
Hi, i was looking for a shell utility using sed or awk that allows to switch the case sensitive of the letters of a word. I mean, if i have a word like "ShElLsCrIpT" the result of applying the shell script should be "sHeLlScRiPt". The first idea was to read the word and cut letter by letter and pass the letter to a function and check if the letter is upper case or lower case and return the switched letter. Perhaps this is too complex and before to do it i was wondering if somebody may know an easier and simple way to do it. Thanks a lot in advance, Alex 2003/10/2...

Question to awk and sed
Hello, I tried to get an output of all MAC-addresses by the following command tcpdump | awk '/reply/ {print $6}' | sed 's/:/ /g' There must be a problem with the output of awk and the pipe to sed for a simple substitution as no address is printed. Is it possible to integrate the subtitution to awk? I appreciate any help you can give me. T h o m a s B -- "A patriot must always be ready to defend his country against his government." Edward Abbey Thomas Barth wrote, On 05/20/2005 10:16 AM: > Hello, > I tried to get an output of all MAC-addresses by the f...

awk sed question...
Dear Friends, I need a code that can replace a var_text in a line into xyz so I can replace it later. The var_text can be a1, a2, a3, a4, e.g. stainless mud pan,construction,,,4,4,1196924152,,a2,, jonaharah@gmail.com wrote: > > I need a code that can replace a var_text in a line into xyz so I can > replace it later. The var_text can be a1, a2, a3, a4, > > > e.g. > > stainless mud pan,construction,,,4,4,1196924152,,a2,, sed "s/a[1-4]/xyz/" -- Best regards | Be nice to America or they'll bring democracy to Cyrus | your count...

sed and awk usage?
Hi, I have to re-write some data, and hope to find some help using sed or awk to do so. The lines are similar to: 2007-01-22,1.55,1.75,1.55,1.61,122100,1.61 and need to be in form: 22-Jan-07,1.55,1.75,1.55,1.61,122100,1.61 All days, months and years need to be re-written in first csv field. Any help, please? I don't know sed or awk well enough to make much progress, thanks. On Tue, 23 Jan 2007 19:33:46 -0800, grus wrote: > Hi, I have to re-write some data, and hope to find some help using sed or > awk to do so. > > The lines are similar to: > 2007-01-22,1.55,1.75,1....

Help with sed/awk ?
Hello all, When I dump (parts) of a postgres database into a textfile I get it in the following format (each users data on three rows). The reason for it is probably that the last field contain cr/lf characters. ------------------------------------------------------- 45|User1|Lastname||555-12345||Fakestreet 1 ODF4/145:146 dBm: 13.3 46|User2|Lastname||555-12346||Fakestreet 2 ODF2/43:44 dBm: 13.42 47|User3|Lastname||555-12347||Fakestreet 3 ODF5/7:8 dBm: 13.36 ------------------------------------------------------- What I want but haven't been able to achieve is t...

Web resources about - Whitespace in SED - comp.lang.awk

Whitespace (programming language) - Wikipedia, the free encyclopedia
... secondary sources about the topic. If notability cannot be established, the article is likely to be merged , redirected , or deleted . Whitespace ...

WhiteSpaces FCC Solution
Spectrum Bridge's White Space database solution is certified by the FCC. The Commission’s Part 15 rules (47 C.F.R. § 15.701 et seq.) require ...

Whitespace - A Writer, Editor and Organizer For Your Notes and Ideas on the App Store on iTunes
Get Whitespace - A Writer, Editor and Organizer For Your Notes and Ideas on the App Store. See screenshots and ratings, and read customer reviews. ...

Whitespace Gains Backup And Restore Functionality Plus More With First Ever Update
The minimalist note-taking app Whitespace has just received its first ever update. First and foremost, the update ensures that Whitespace is ...

Whitespace, A Fantastic Text And Picture-Based Note Taking App
Whitespace is an note-taking iPhone app that kind of combines Q Branch’s Vesper with a corkboard concept (only without the actual cork texture ...

Effective use of whitespace in design
I love whitespace when it’s used properly. It’s such an integral part of a design that is often ignored.

FCC votes unanimously in favor of using whitespace for 'super WiFi'
Just as we suspected earlier this month, the Federal Communications Commission has voted unanimously (that's five yeas and zero nays, if you ...

FCC's Whitespace Ruling: The Real Wi-Fi Revolution Is About to Happen
We live in a Wi-Fi age surrounded by impressive wireless gizmos thanks to relaxed rules about wireless transmission. Now the FCC is about to ...

Why Data First Development Rapidly Fills Application Whitespace
Technology leaders seeking a way to fill the yawning whitespace that exists in most companies should consider taking a data first approach to ...

whitespace
Image courtesy of Flickr user Cillian Storm.

Resources last updated: 1/24/2016 11:51:48 AM