Seen
Seen

Reputation: 4194

Substitute backslash plus pipe in VI/Linus

I have a pipe(|) separated file, but there some "\|" which messed up for further processing. How can I substitute "\|" into " |"(space pipe)?

I tried :/\/| in vi, it can find " \|" but I tried %s//\//|/ //|/g it is not working. Is there anyway I can do it?

Upvotes: 1

Views: 121

Answers (2)

Frédéric Hamidi
Frédéric Hamidi

Reputation: 262939

You can issue the following command:

:1,$s/\\|/ |/g

Upvotes: 2

Kent
Kent

Reputation: 195059

in vim, try:

%s/\\|/ |/g

it will change

aa\|bb|cc

into

aa |bb|cc

or using sed:

sed -i 's/\\|/ |/g' file

Upvotes: 2

Related Questions