![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Linux RedHat, Ubuntu, SUSE, Fedora, Debian, Mandriva, Slackware, Gentoo linux, PCLinuxOS. All Linux questions here! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problem fixing e1000gx ni to 100fdx / Solaris 10 / T5220 | moofoo | SUN Solaris | 6 | 01-14-2008 04:34 AM |
| fixing the error message when grep doesn't finds the pattern. | silver123 | UNIX for Dummies Questions & Answers | 1 | 03-03-2006 05:59 AM |
| Fixing line length in a file | dbessell | UNIX for Advanced & Expert Users | 2 | 08-04-2003 07:40 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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 01:09 PM.. Reason: added code tags |
|
||||
|
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 |
|
||||
|
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 |
|
||||
|
Bah! Use 'awk':
Code:
awk '/^CREATE VIEW/ && !/OPSDM02/{$3="OPSDM02."$3};{print}' infile > outfile
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|