Hi,
wondering if anyone could help me, been racking my brain. am sure it's a simple one for the guru's amongst you......
I have used cat to get the line number from a file and wanted to list all between them lines. I used variables, however it seem like the second variable seems to have a few leading spaces. which sed -n does not like.
does anyone know how to avoid the extra spaces ???
Thanks for all your help in advance. Its the weekend so apoligies if I dont get back to anyone if I get any replies ;-)
thanks Raj
solaris 10
---script---
set -x
awk '{ print NR, $0}' ods_online.log > lines
all=`cat ods_online.log|wc -l`
mash=`cat lines |grep 2009|tail -1| awk {'print $1'}`
echo $mash
echo $all
cat ods_online.log |sed -n "'${mash},${all}p'"
--run output--
./m.sh
+ awk { print NR, $0} ods_online.log
+ 1> lines
+ + wc -l
+ cat ods_online.log
all= 100027
+ + cat lines
+ grep 2009
+ awk {print $1}
+ tail -1
mash=99340
+ echo 99340
99340
+ echo 100027
100027
+ sed -n '99340, 100027p'
+ cat ods_online.log
Unrecognized command: '99340, 100027p'
-----------------------------------------------
-------so its looks like it does not like the spaces-----------------
> cat ods_online.log|sed -n '99340, 100027p'
sed: command garbled: 99340, 100027p
-------manually removed spaces from command----works fine------
> cat ods_online.log|sed -n '99340,100027p'
Fri Oct 23 00:04:42 2009
00:04:42 Checkpoint Completed: duration was 0 seconds.
00:04:42 Fri Oct 23 - loguniq 122238, logpos 0x12719044, timestamp: 0x4dd9d335 Interval: 11014
00:04:42 Maximum server connections 97
00:04:42 Checkpoint Statistics - Avg. Txn Block Time 0.000, # Txns blocked 0, Plog used 2, Llog used 1
----------------------------------------------------------------