![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Linux RedHat, Ubuntu, SUSE, Fedora, Debian, Mandriva, Slackware, Gentoo linux, PCLinuxOS. All Linux questions here! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problem fixing e1000gx ni to 100fdx / Solaris 10 / T5220 | moofoo | SUN Solaris | 6 | 01-14-2008 01:34 AM |
| fixing the error message when grep doesn't finds the pattern. | silver123 | UNIX for Dummies Questions & Answers | 1 | 03-03-2006 02:59 AM |
| Fixing line length in a file | dbessell | UNIX for Advanced & Expert Users | 2 | 08-04-2003 03:40 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
fixing with sed
I am trying to replace the value of $f3 but its not working . I don't know what I am missing here .
Code:
cat dim_copy.20080516.sql | grep -i "create view" | grep -v OPSDM002 | while read f1 f2 f3 f4 f5 f6 f7 f8 f9
do
echo " $f3 "
sed -e s/"${f3}"/OPSDM002."${f3}"/ dim_copy.20080516.sql > dim_copy.20080516.sql1
done
Thanks in advance Last edited by Yogesh Sawant; 05-23-2008 at 09:09 AM. Reason: added code tags |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Post some lines of the sql file and the desired output.
Regards |
|
#3
|
|||
|
|||
|
The SQL file is
CREATE VIEW MOUSE_UHC AS SELECT DT_SYS_ID ,DAY_ABBR_CD,LST_DAY_MO_IND,MONTH_NBR,FULL_DT,DAY_NBR FROM OPSDM002.DIM_COPY; CREATE VIEW OPSDM002.TABLE_UHC AS SELECT DAY_ABBR_CD,LST_DAY_MO_IND,MONTH_NBR,FULL_DT,DAY_NBR,LOAD_DT,WEEK_NBR_YR,SEQ_NBR FROM OPSDM002.DIM_COPY; CREATE VIEW RAT_UHC AS SELECT DT_SYS_ID ,DAY_ABBR_CD,LST_DAY_MO_IND,MONTH_NBR,FULL_DT,DAY_NBR The desired output is CREATE VIEW OPSDM002.MOUSE_UHC AS SELECT DT_SYS_ID ,DAY_ABBR_CD,LST_DAY_MO_IND,MONTH_NBR,FULL_DT,DAY_NBR FROM OPSDM002.DIM_COPY; CREATE VIEW OPSDM002.TABLE_UHC AS SELECT DAY_ABBR_CD,LST_DAY_MO_IND,MONTH_NBR,FULL_DT,DAY_NBR,LOAD_DT,WEEK_NBR_YR,SEQ_NBR FROM OPSDM002.DIM_COPY; CREATE VIEW OPSDM002.RAT_UHC AS SELECT DT_SYS_ID ,DAY_ABBR_CD,LST_DAY_MO_IND,MONTH_NBR,FULL_DT,DAY_NBR Thanks |
|
#4
|
|||
|
|||
|
If I understand correctly what you try to do:
Code:
sed -r '/OPSDM002/! s/CREATE VIEW ([^ ]+)/CREATE VIEW OPSDM002.\1/' your_file |
|
#5
|
|||
|
|||
|
Ripat ,
When I run your command i get the following error #sed -r '/OPSDM002/! s/CREATE VIEW ([^ ]+)/CREATE VIEW OPSDM002.\1/' dim_copy.20080516.sql sed: illegal option -- r Usage: sed [-n] Script [File ...] sed [-n] [-e Script] ... [-f Script_file] ... [File ...] Thanks |
|
#6
|
|||
|
|||
|
In that case, here we go with the backslash dance:
Code:
sed '/OPSDM002/! s/CREATE VIEW \([^ ]\+\)/CREATE VIEW OPSDM002.\1/' |
|
#7
|
|||
|
|||
|
Ripat ,
This is not working too. #sed '/OPSDM002/! s/CREATE VIEW \([^ ]\+\)/CREATE VIEW OPSDM002.\1/' dim_copy.20080516.sql sed: /OPSDM002/! s/CREATE VIEW \([^ ]\+\)/CREATE VIEW OPSDM002.\1/ is not a recognized function. Thanks |
|||
| Google The UNIX and Linux Forums |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|