Filtering line out of file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Filtering line out of file
# 1  
Old 10-31-2008
Filtering line out of file

Hy,

I would like to extract lines within following file,
4TX + 4XFUT + 4XBACK + 4Xexp:
theo. actual
start of day: -2 5
end of day: 5 4
profit: 2 -1
====================
trade profit: 9 -2
parameters : -7
vp pivot : 0
base vol : 7
pivot : -1
down slope: -1
up slope : -1
slope 2 : -3
pivot time: 0
price : 2 -8
time decay : 9
tk> tk> tk> tk> tk> tk> -------------------------------
16K + 16KSUB + 16TSUB2:
theo. actual
start of day: 0 0
end of day: 0 0
profit: 0 0
====================
trade profit: 0 0
parameters : 0
vp pivot : 0
base vol : 0
pivot : 0
down slope: 0
up slope : 0
slope 2 : 0
pivot time: 0
price : 0 0
time decay : 0
tk> -------------------------------
17 + 17SUB + 1&SUB2:
theo. actual
start of day: 0 0
end of day: 0 0
profit: 0 0
====================
trade profit: 0 0
parameters : 0
vp pivot : 0
base vol : 0
pivot : 0
down slope: 0
up slope : 0
slope 2 : 0
pivot time: 0
price : 0 0
time decay : 0
tl> tl> tl> tl> tl> -------------------------------

I need all values for "start of day", "end of day" and "profit"
with account for each one i.e 4TX "start of day", "end of day" and "profit".

thanks
# 2  
Old 10-31-2008
Assuming you sample really does match the data and there are no trailing spaces:
Code:
grep -e '^profit'   -e  '^end of day'   -e '^start of day'    -e  ':$' oldfilename > newfilename

will write those lines to a new file
# 3  
Old 10-31-2008
getting error :-

grep: illegal option -- e
# 4  
Old 10-31-2008
or.
Code:
grep -E '^(profit|(end|start) of day)|:$'  file > newfile

# 5  
Old 10-31-2008
still no joy, now i getting error:-

grep: illegal option -E
# 6  
Old 10-31-2008
Hammer & Screwdriver Perhaps try this format

Code:
>egrep -e "^Profit|^End|^Start" myinputfile

# 7  
Old 10-31-2008
no getting any errors, but when I ran echo $? which returns 1
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help with filtering records in a file

Hi, I have following records in a file more file1.txt setting applicaction ABC for user setting applicaction CDE for user setting applicaction XXX for user logging applicaction XXX for user I need to filter out records which have strings " setting... (5 Replies)
Discussion started by: manid
5 Replies

2. Shell Programming and Scripting

sed filtering lines by range fails 1-line-ranges

The following is part of a larger project and sed is (right now) a given. I am working on a recursive Korn shell function to "peel off" XML tags from a larger text. Just for context i will show the complete function (not working right now) here: function pGetXML { typeset chTag="$1" typeset... (5 Replies)
Discussion started by: bakunin
5 Replies

3. Shell Programming and Scripting

Filtering first file columns based on second file column

Hi friends, I have one file like below. (.csv type) SNo,data1,data2 1,1,2 2,2,3 3,3,2 and another file like below. Exclude data1 where Exclude should be treated as column name in file2. I want the output shown below. SNo,data2 1,2 2,3 3,2 Where my data1 column got removed from... (2 Replies)
Discussion started by: ks_reddy
2 Replies

4. Shell Programming and Scripting

Multi-line filtering based on multi-line pattern in a file

I have a file with data records separated by multiple equals signs, as below. ========== RECORD 1 ========== RECORD 2 DATA LINE ========== RECORD 3 ========== RECORD 4 DATA LINE ========== RECORD 5 DATA LINE ========== I need to filter out all data from this file where the... (2 Replies)
Discussion started by: Finja
2 Replies

5. Shell Programming and Scripting

Parsing and filtering multiline text into comma separated line

I have a log file that contains several reports with following format. <Start of delimiter> Report1 header Report1 header continue Report1 header continue Record1 header Record1 header continue Record1 header continue field1 field2 field3 field4 ------... (1 Reply)
Discussion started by: yoda9691
1 Replies

6. UNIX for Dummies Questions & Answers

Filtering records from 1 file based on some manipulation doen on second file

Hi, I am looking for an awk script which should help me to meet the following requirement: File1 has records in following format INF: FAILEd RECORD AB1234 INF: FAILEd RECORD PQ1145 INF: FAILEd RECORD AB3215 INF: FAILEd RECORD AB6114 ............................ (2 Replies)
Discussion started by: mintu41
2 Replies

7. Shell Programming and Scripting

filtering the rows in a file

hi all, please help on this isssue, i have a file which contains something like this and i want to seprate the servers which has vasd.pid ,i need only server names. i want output something like this which vasd.pid . server1 server3 server4 (4 Replies)
Discussion started by: sudharson
4 Replies

8. UNIX for Dummies Questions & Answers

Filtering a file

I have a list of directories looking something like; /usr/local/1/in /usr/local/1/out /usr/local/1/archive /usr/local/2/in /usr/local/2/out /usr/local/2/archive /usr/local/3/in /usr/local/3/out /usr/local/3/archive Is there a way I can filter the out and archive directories so I... (5 Replies)
Discussion started by: JayC89
5 Replies

9. UNIX for Dummies Questions & Answers

problem in filtering the file

-------------------------------------------------------------------------------- Hi, Plz help me out with this. I have some requirement like this..... I have a file like this... * CS sent email (11.20) CALYPSO 1031276 9076673 CDSHY FAILED Nov 19 2007 7:28AM OASYS: Unable to find CUSTOMER... (0 Replies)
Discussion started by: adityam
0 Replies

10. Shell Programming and Scripting

Urgent: Filtering a File

Hi all I need to write a small shell script, where we have one Log file and another File 1 containing some tags in it. My log file can have multiple tags in it which can be other than the ones that are part of File 1. So I need to write a script that will run and test whether the tags... (5 Replies)
Discussion started by: HItesh
5 Replies
Login or Register to Ask a Question