I am trying to replace the line which has string "tablespace" not case senstive....
with below simple script: mysrcipt.sh
sed "s/[Tt][Aa][Bb][Ll][Ee][Ss][Pp][Aa][Cc][Ee].*/TABLESPACE USERS/g" create_table > tmp
mv tmp create_table
Is there any better way to do it? If Search string tooooooo long it will be tough to code in above script?
zaxxon
2
GNU sed can do this:
echo "TaBlE SpAcE"| sed 's/table space/Table Space/ig'
Table Space
The "i" stands for "ignore case".
GNU awk can do this:
echo "TaBlE SpAcE"| awk '{IGNORECASE=1; sub(/table space/,"Table Space"); print }'
Table Space
1 Like
clx
3
if GNU versions not available,
echo 'TableSpace some text' | perl -pe 's/tablespace.*/TABLESPACE USERS/i'
---------- Post updated at 12:01 PM ---------- Previous update was at 11:56 AM ----------
BTW, You can at least reduce the number of opening and closing brackets in your solution.
echo 'TableSpace sometext' | sed 's/[TtAaBbLlEeSsPpAaCcee].*/TABLESPACE USERS/g'
Though, I am not sure this'd work always?
---------- Post updated at 12:19 PM ---------- Previous update was at 12:01 PM ----------
No, I think that wont work. please ignore that later part.
1 Like
kurumi
4
$ ruby -pne '$_.gsub!(/tablespace/i,"TABLESPACE")' file
1 Like
Or the rather quaint
$ echo "TaBlESpAcEpepperdepep"| sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/;s/tablespace.*/TABLESPACE USERS/'
TABLESPACE USERS
1 Like