How to replace string

I have input file line as

create table user_area

But in abve line anything can come after create table , so I have to take from create table(space) to (next space)

I want to change it to

create table user_work

sed 's/create table [^ ]*/create table user_work/' file >newfile

crt=`sed -n '2,$p' /home/nbk3eyb/files/ccc_conduit_gci_20080922_DDL.txt | sed 's/create table [^ ]*/create table user_work/'`

but its not working

$ grep -i "create table" <<YOUR_FILE_NAME>> |awk '{print $3}' > <<NEW_FILENAME>>

The awk solution contains a Useless Use of Grep.

awk 'tolower($0) ~ /create table/ { print $3 }' \
  /home/nbk3eyb/files/ccc_conduit_gci_20080922_DDL.txt

However, that's a bit rich in assumptions about what you want. Anyway, it's not really clear which part is not working. Does $crt not contain the string you want? Your script prints the whole file except the first line with the table name changed; is that what you want? The awk script just extracts the one line. If that's what you want then the following sed script also does that, with the additional condition that it skips the first line.

sed -n '2,$s/create table [^ ]*/create table user_work/p' \
  /home/nbk3eyb/files/ccc_conduit_gci_20080922_DDL.txt

If you do want the whole file except the first line, then take out the -n and the very final p after the last slash; however, that's basically the same as what you already have, albeit simplified and refactored. Again, if you could expand on what doesn't work and how you would like to fix it, we can try to work it out.