Deleting lines above a certain line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Deleting lines above a certain line
# 1  
Old 10-11-2007
Deleting lines above a certain line

Hi,

I have a file that gets automatically generated and it would look something like

sakjsd
adssad
{{word}}

sddsasd
dsdsasa
.
.
.


So basically what I want to do is just keep the stuff below the {{word}} marker. The marker includes the brackets. Is there any command to delete the "{{word}}" and everything above it and just keep what is below it? Thanks!
# 2  
Old 10-11-2007
Code:
sed '1,/{{word}}/d' myFile

# 3  
Old 10-11-2007
Code:
awk '/{{word}}/{f=1;next}f' file

# 4  
Old 10-11-2007
cool thanks a bunch!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Get an output of lines in pattern 1st line then 10th line then 11th line then 20th line and so on.

Input file: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 (6 Replies)
Discussion started by: Sagar Singh
6 Replies

2. Shell Programming and Scripting

Deleting all the N lines after the line in which text is found.

Hi! I want to delete N (say 10) lines after the line which text is found in a file "A".Also to delete the line in which the text is found. Only one occurrence of the search string in the file "A" The text to be deleted is in another text file "B". All the search texts in the file "B" are in... (3 Replies)
Discussion started by: shahid1632
3 Replies

3. Shell Programming and Scripting

Deleting double quoted string from a line when line number is variable

I need to remove double quoted strings from specific lines in a file. The specific line numbers are a variable. For example, line 5 of the file contains A B C "string" I want to remove "string". The following sed command works: sed '5 s/\"*\"//' $file If there are multiple... (2 Replies)
Discussion started by: rennatsb
2 Replies

4. UNIX for Dummies Questions & Answers

Deleting a pattern in UNIX without deleting the entire line

Hi I have a file: r58778.3|SOURCES={KEY=f665931a...,fw,221-705}|ERRORS={16_1:T,30_1:T,56_1:C,57_1:T,59_1:A,101_1:A,115:-,158_1:C,186_1:A,204:-,271_1:T,305:-,350_1:C,368_1:G,442_1:C,472_1:G,477_1:A}|SOURCE_1="Contig_1092402550638"(f665931a359e36cea0976db191ff60ff09cc816e) I want to retain... (15 Replies)
Discussion started by: Alyaa
15 Replies

5. Shell Programming and Scripting

Deleting a matching string(line) which is also in other lines

Hi, i need help with my shell script I have a file input.txt containing the following contents /. /usr /usr/share /usr/share/doc /usr/share/doc/wine /usr/share/doc/wine/copyright /usr/share/doc/wine/changelog.Debian.gz I need output as /usr/share/doc/wine /usr/share/doc/wine/copyright... (3 Replies)
Discussion started by: Amit0991
3 Replies

6. Shell Programming and Scripting

deleting lines in ex

Hello, im using ex to manipulate some text. Im trying to delete all the lines except those on which a certain regex can be found. the important part of the script: ex temp << 'HERE' g/regex/p HERE this command prints the lines I want to end up with, but it doesnt delete the others.... (2 Replies)
Discussion started by: drareeg
2 Replies

7. Shell Programming and Scripting

Deleting particular lines.

hi all, i have got a scenario in which i need to delete all the lines that ends with file names. e.g. input can be cms/images/services_icons/callback.png cms/cms/images/services_icons/sync.php cms/cms/images/services_icons and output should be cms/cms/images/services_icons ... (13 Replies)
Discussion started by: kashifv
13 Replies

8. Shell Programming and Scripting

Deleting Characters at specific position in a line if the line is certain length

I've got a file that would have lines similar to: 12345678 x.00 xx.00 x.00 xxx.00 xx.00 xx.00 xx.00 23456781 x.00 xx.00 xx.00 xx.00 xx.00 x.00 xxx.00 xx.00 xx.00 xx.00 34567812 x.00 xx.00 x.00 xxx.00 xx.00 xx.00 xx.00 45678123 x.00 xx.00 xx.00 xx.00 xx.00 x.00 xxx.00 xx.00 xx.00 xx.00 xx.00... (10 Replies)
Discussion started by: Cailet
10 Replies

9. Shell Programming and Scripting

deleting particular lines and moving a line up using perl/sed

Hi, I need convert a dump file in the following format : (please note that line numbers are provided for easy look) Original file: 1 2007-10-2482.90 No trade 0 0.00 100000.00 2 100000.00 3 0.00 4 HOLD 5 2007-10-2589.75 Bought 1114 1114 100000.00 0.00 ... (5 Replies)
Discussion started by: sabyasm
5 Replies

10. Programming

deleting lines

I am spooling a file from oracle and trying to delete the last line of the spooled file which I am unable to do. Problem is that this file can have multiple records each time and I have no way of knowing how many because the amount can vary. I had an idea of using a while loop to read the... (1 Reply)
Discussion started by: supercbw
1 Replies
Login or Register to Ask a Question