'sed commmad in Ubuntu

The command I am using is this:

sed 's/\ (/\(/g' file2

The text I am getting as its output is this:

swissadme\(9).csv

The output I want in this is:

swissadme\ (9).csv

I want space between the two "\" that I am using.



Solution 1:[1]

The arguments for s are s/PATTERN/REPLACEMENT/, but you seem to have them reversed. What you want to replace comes first, the result comes second.

Also, backslash is special for sed and needs to be doubled to match or output literally. So, the working command is

sed 's/\\(/\\ (/g'

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 choroba