treat escape sequence using sed in bash script 본문

Programming

treat escape sequence using sed in bash script

halatha 2011. 8. 19. 23:24
case
1. dump monetdb database into file (escape sequences show like '\t', '\n' properly)
2. split it into table by table using bash script (escape sequences show like 't', 'n')
3. bulk input table dump file into other database
problem: cannot write escape sequence properly (want: '\t', '\n' / real: 't', 'n')
solution: use eight back slashes

...
_line=`echo $_line | sed 's/'\''\([t|n]\)'\''/'\''\\\\\\\\\1'\''/g'`
echo "${_line}" >> $_file
...
Comments