Add spaces to a file using bash
Hello, I've been trying lately to replace certain characters in a file with that same character, adding spaces before and after. I tried with sed and awk, but it doesn't seem to work. My script reads like this right now:
#!/bin/bash for i in $( cat char_file ); do p_space=" $i " gawk -v pattern="$i" -v p_space=" $i " '{gsub(pattern,p_space);}' target_file done The characters include numbers, @, #... May anybody lend me a hand? Thanks in advance... |
Hi,
Here's a solution using sed: Code:
#!/bin/bash |
It still doesn't work
Thanks for answering but it doesn't work... I already tried something like that and it seems to me that sed has problems with the spaces...
|
Hi,
What doesn't work/ is the error message? It seems to work on my box: Code:
$ cat char_file |
I beg your pardon, the char file was corrupt. It works right now. I changed it and everything went into place inmediately. I just don't know why I wasn't getting a error message. Thanks a lot for your assistance...
|
Hi,
Nice to read it works :) |
All times are GMT -5. The time now is 12:56 PM. |