It is currently Thu, 20 Jan 2022 05:10:54 GMT



 
Author Message
 SED / Line / (Need to get data from searched line from specific char to char)
Hello !

I need to search line from text file which contains specific text in start
of it.
Then I need to get text from specific place in a line. Like craracters from
10 to 20.

File looks like this:
A             5308,99
B             -2342,23
*** Total -34505,40
* D           2344,30

I need to get that Total number.

So the guestion is what utility should I use and how to do it ?

I'm using SED 2.05 in NT. I also don't find newer SED for NT.

So I need to do it in NT !

I know this is UNIX group, but NT-users don't know these kind of things....

Thanks !
Tomi Koivisto
Finland



 Fri, 29 Mar 2002 03:00:00 GMT   
 SED / Line / (Need to get data from searched line from specific char to char)

sed -n 's/^\*\*\* Total //p'

You might need to change the 's to "s then; I seem to recall
that MS command interpreters don't use 's for parameter quoting.

                --Ken Pizzini



 Fri, 29 Mar 2002 03:00:00 GMT   
 SED / Line / (Need to get data from searched line from specific char to char)
Ken's reply is a good solution to specific
problem:
Ken's reply including  cahnging ' to ":

In general to find lines starting with X
and selecting a string starting with first Y
and going to last Z try something like:
sed -n "s/^X.*\(Y.*Z\)/\1/p
or if you want a piece after the first Y
and finishing just before the last Z:
sed -n "s/^X.*Y\(.*\)Z/\1/p

Hope these are correct and this helps.

dick

rbotting at CSUSB edu
Computer Scientist, Sys Admin, Consultant, Researcher, and Reviewer
http://www.csci.csusb.edu/dick



 Sat, 30 Mar 2002 03:00:00 GMT   
 SED / Line / (Need to get data from searched line from specific char to char)

I recall using Unix utilities under NT so this simple solution
might be of some use to you.

grep Total file | cut -c 10-20

does exactly what you asked.

The easy sed solution depends on your exact line format but
is going to be something like:
s/^\*\*\* Total //p    
--
David Kennedy,                      | kenne...@nortelnetworks.com
Northern Ireland Telecommunications | ESN:   6 751 2678
  Engineering Centre (NITEC),       | Phone: 01232 362678
Nortel Networks                     | Fax:   01232 363170



 Mon, 01 Apr 2002 03:00:00 GMT   
 
   [ 4 post ] 

Similar Threads

1. reversing lines char by char, but not the line order in a file

2. sed: substitute a char with a line break

3. A sed purist's problem: reversing lines char by char, but not the line order in a file

4. Need help displaying line and graphics chars under SCO 5


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software