Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

repalce every second : occurence wit space in each line 6

Status
Not open for further replies.

w5000

Technical User
Nov 24, 2010
223
PL

hello

how to repalce every second : occurence wit space in each line?

thank you.
 
Like this ?
Code:
sed 's!:! !2' /path/to/input

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
awesome!

thank you!

PS. could you please explain how this "stuff" works in your solutions?
 
man sed

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi

See if you can get some meaning from this :
Code:
[white].[/white]    [red],------------------------ substitute[/red]
     [red]|[/red]        [green],--------------- this[/green]
     [red]|[/red]  [green]______|_______[/green]    [blue],--- with this[/blue]
     [red]|[/red] [green]/              \[/green]  [blue]/\[/blue] [fuchsia],- globally ( all occurrences )[/fuchsia]
sed '[red]s[/red]/[green]\([^:]*:[^:]*\):[/green]/[blue]\1 [/blue]/[fuchsia]g[/fuchsia]' /input/file
        [olive]\____________/   ^[/olive]
               [olive]|keep this|[/olive]
               [olive]`---------'[/olive]

 [red],--------------- start capture[/red]
 [red]|[/red]  [green],-----,------ character class[/green]
 [red]|[/red] [green]_|    _|[/green]   [blue],-- end capture[/blue]
[red]/\[/red][green]/  \  /  \[/green] [blue]/\[/blue],- literal ":"
[red]\([/red][highlight #cfc][green][[/green][maroon]^[/maroon]:[green]][/green][/highlight][teal]*[/teal]:[highlight #cfc][green][[/green][maroon]^[/maroon]:[green]][/green][/highlight][teal]*[/teal][blue]\)[/blue]:
   [maroon]|[/maroon]| [teal]`---------- previous item 0 or more times[/teal]
   [maroon]|[/maroon]`------------ literal ":"
   [maroon]`------------- any character excepting the following ones[/maroon]

Feherke.
[link feherke.github.com/][/url]
 
Nice piece of ASCII art there feherke!

Annihilannic
[small]tgmlify - code syntax highlighting for your tek-tips posts[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top