简体   繁体   中英

Using sed to replace tab with spaces

I'm trying to replace the tab with 4 spaces, using sed, but it is not working.

Here is my code:

sed -i '{s/\t/ \{4\}/g}' filename

Any suggestion is appreciate.

In sed replacement is not supposed to be a regex, so use:

sed -i.bak $'s/\t/    /g' filename

On gnu-sed even this will work:

sed -i.bak 's/\t/    /g' filename

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM