![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Using grep to extract line number | mskarica | Shell Programming and Scripting | 8 | 06-26-2008 02:47 AM |
| check whether variable number or string | rolex.mp | UNIX for Dummies Questions & Answers | 4 | 02-22-2007 12:12 AM |
| extract from string variable into new variables | Sniper Pixie | UNIX for Dummies Questions & Answers | 2 | 03-03-2006 10:49 AM |
| Extract emp number from an error file. | jagannatha | UNIX for Dummies Questions & Answers | 2 | 05-30-2003 09:39 AM |
| How to extract a portion of a string from the whole string | ds_sastry | UNIX for Dummies Questions & Answers | 2 | 09-29-2001 10:40 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
hi,I am new to shell script,I have String,like this:
Number of rows exported: 5321 the numbe at end could changing,how can I extract this number and assign it to a variable,then use it later in script. thanks. |
|
||||
|
first command is
db2 "export to ACTIONS.dat of del select * from ACTIONS" it will created following message: SQL3104N The Export utility is beginning to export data to file "ACTIONS.dat". SQL3105N The Export utility has finished exporting "238" rows. Number of rows exported: 238 I use grep get last line,and use you code get '238',I want assign this number to a variable like $Number,then i use another command like db2 "insert into log (tablename,number) values('ACTIONS',$Number) to insert this number to a db2 table log problem is how can i combine first db2 command with the extract commands(grep and awk) to assign this number to that variable $Number |
|
||||
|
hi,thanks for reply,still can not make it work,here is several tests i make,hope it give you some idea of problems.
>x=123 >echo $x 123 >x=`db2 "export to ACTIONS.dat of del select * from ACTIONS" |grep "Number of rows exported" | awk -F: '{print $2}'` >echo $x >db2 "export to ACTIONS.dat of del select * from ACTIONS" |grep "Number of rows exported" | awk -F: '{print $2}' 238 It is sames that combination clear the variable x,last one print "238",as I am a newbie,I don't know how to make it work.by the way,I am using bash,'>' is command prompt here.thanks |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|