![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| help me in sending parameters from sqlplus script to unix shell script | Hara | Shell Programming and Scripting | 2 | 01-29-2008 12:31 PM |
| Shell Script: want to insert values in database when update script runs | ring | Shell Programming and Scripting | 1 | 10-25-2007 12:06 AM |
| here document to automate perl script that call script | hogger84 | Shell Programming and Scripting | 3 | 10-22-2007 07:15 AM |
| returning to the parent shell after invoking a script within a script | gurukottur | Shell Programming and Scripting | 5 | 09-26-2006 04:05 AM |
| return valuse from child script to parent script | borncrazy | Shell Programming and Scripting | 1 | 08-20-2004 12:39 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi, as i spool some data into a tmp.log file ${SQL_LOG} which contained the below :
1 row updated. 1 row created. 111 ---------- 111 Commit complete. then as i wanted to cut the value of 111 into a variable ,i put as this ksh script and echo it out: JOB_ID=`head -10 ${SQL_LOG} | -b cut 1-10 ' echo $JOB_ID but the echo will print as one straight line : 1 row updated. 1 row created. 111 ---------- 111 How do i write ksh script to cut the value 111 out ??? Thanks |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Got it, I had steal it from another forum, but I knew it was possible
I always struggle with grep'ing on linenumbers, but there is a very easy function from AWK : JOB_ID=`awk 'NR>=8 && NR<=9 && /[[0-9]]*/ {print}' ${SQL_LOG}` NR>=8 Means that linenumber must be above 8 /[[0-9]]* Means that it should match the characters 0123456789 I think it's quiet clear, if you don't make it to understand, please let me know. Regs David |
|
#3
|
|||
|
|||
|
Hi David,
thanks for your help ! Based on your script as shown below : JOB_ID=`awk 'NR>=8 && NR<=9 && /[[0-9]]*/ {print}' ${SQL_LOG}` As your /[[0-9]]* means it will get the line when it encounter any integer value ,right ?? so even if i wanted to cut a sentence in row 10 with 1111 on it , i could use the below script : JOB_ID=`awk 'NR=10 && /[[0-9]]*/ {print}' ${SQL_LOG}` Am i right?? thanks a lot!! Last edited by blueberry80; 07-25-2003 at 07:03 AM. |
|
#4
|
||||
|
||||
|
You're a quick learner
The question is answered in your original post. Glad to be of service. Regs David |
|
#5
|
|||
|
|||
|
Hi,
thanks for your help but when i tried out using the script : JOB_ID=`nawk 'NR=5 {print}' ${SQL_LOG}` to cut from this log file : 1 row updated. 1 row created. 111 ---------- 111 Commit complete. it will echo out this : 1 row updated. 1 row created. 111 ---------- 111 Commit complete. instead of just getting out the '111'. why is it that the log file become one straight line when i echo out and i am unable to cut the 111. Thanks ! |
|
#6
|
||||
|
||||
|
cut -b 1-3
will do what you want. |
||||
| Google The UNIX and Linux Forums |