Just white space, I'm doing things with bash scripts. On Sat, 21 Dec 2019, Linux for blind general discussion wrote: > Date: Sat, 21 Dec 2019 20:25:34 > From: Linux for blind general discussion <blinux-list@xxxxxxxxxx> > To: Linux for blind general discussion <blinux-list@xxxxxxxxxx> > Subject: Re: ex syntax? > > Tim here. > > If you're using ed or sed rather than ex/vi/vim, it's pretty easy > depending on what constitutes a "word" (do you include punctuation > as word-separation, or just white-space? What about contractions > like "can't" or abbreviations like "Dr."?). You can use > > 6s/[^[:space:]]\{1,\}/replacement/6 > 6s/[[:alpha:]]\{1,\}/replacement/6 > > in both cases. The first 6 is the line-number, the 2nd 6 is the 6th > word in the line. > > In ex/vi, it's a bit more complex because they don't support the > numeric flag at the end to indicate the 6th one, so you'd have to do > something atrocious like > > 6s/\(\([^[:space:]]\{1,\}[[:space:]]\{1,\}\)\{5\}\)[^[:space:]]*/\1replacement/p > > (that "5" is the 5 words before the one you want to replace). It > would generally be easier to just retype the line. > > It might be easier to prompt for a replacement: > > 6s/[^[:space:]]\{1,\}/xxx/gc > > and then answer "no" 5 times, then answer "yes" for the 6th one. > > If you're running the ex-mode of vim instead of vi, vim provides more > powerful regular expressions so you can do > > 6s/\(\W*\zs\w\+\)\{6}/replacement > > Vim's regex also makes it easy to define what constitutes a > word-vs-not-a-word (using "\w" and "\W") or > whitespace-vs-non-whitespace (using "\s" and "\S"). Depending on how > you define a "word" the ed/sed/ex/vi versions get a lot messier. > > Hope this helps, > > -Tim (the vi/vim/ed/ex geek behind the @ed1conf account on Twitter) > > > On December 21, 2019, Linux for blind general discussion wrote: > > On line 6 of a file what is the command to delete word 6 on that > > line? A long time ago when the bsd learn utility was working on a > > system I studied the advanced ex lessons and unfortunately forgot > > that syntax. > > > _______________________________________________ > Blinux-list mailing list > Blinux-list@xxxxxxxxxx > https://www.redhat.com/mailman/listinfo/blinux-list > > -- _______________________________________________ Blinux-list mailing list Blinux-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/blinux-list