Hi,
I have file:
aaaaa
bbbbbb
cccccccc
dddddd
.....
begin of blok
....
end of blok
...
eeee
ffffffff
I need file:
begin of blok
....
end of blok
Thanks
I have file:
aaaaa
bbbbbb
cccccccc
dddddd
.....
begin of blok
....
end of blok
...
eeee
ffffffff
I need file:
begin of blok
....
end of blok
Thanks
All I can think of is
# 10000 chosen at random
cat <file> | grep -A 10000 "begin of blok" | grep -B 10000 "end of blok"
or
FIRST_LINE=`grep -n "begin of blok" <file> | cut -f1 -d':'`
LAST_LINE=`grep -n "end of blok" <file> | cut -f1 -d':'`
DIFF=`expr ${LAST_LINE} - ${FIRST_LINE}`
cat <file> | head -${LAST_LINE} | tail -${DIFF}
Hope that helps.
Graeme
>I have file:
>aaaaa
>bbbbbb
>cccccccc
>dddddd
>.....
>begin of blok
>....
>end of blok
>...
>eeee
>ffffffff
>I need file:
>begin of blok
>....
>end of blok
>Thanks
awk '/begin of blok/,/end of blok/ {print}' filename
> I have file:
> aaaaa
> bbbbbb
> cccccccc
> dddddd
> .....
> begin of blok
> ....
> end of blok
> ...
> eeee
> ffffffff
> I need file:
> begin of blok
> ....
> end of blok
> Thanks
| Hi,
|
| I have file:
|
| aaaaa
| bbbbbb
| cccccccc
| dddddd
| .....
| begin of blok
| ....
| end of blok
| ...
| eeee
| ffffffff
|
|
| I need file:
| begin of blok
| ....
| end of blok
Example:
$ cat foo
foo
bar
baz
BEGIN
...
...
...
...
END
qaz
wsx
zxc
$ sed -n '/BEGIN/,/END/p' foo
BEGIN
...
...
...
...
END
$
--
$ sed -n '/^begin of blok$/,/^end of blok$/w newfile' file
Using `awk' this will do it:
$ awk '/^begin of blok$/,/^end of blok$/{print > "newfile"}' file
---Robert
_____________________________
>
> Hi,
>
> I have file:
>
> aaaaa
> bbbbbb
> cccccccc
> dddddd
> .....
> begin of blok
> ....
> end of blok
> ...
> eeee
> ffffffff
>
> I need file:
> begin of blok
> ....
> end of blok
>
> Thanks
1. "cutting" a file into smaller files?
I have a 20 MB text file that I want to search through for a certain
string.
However, when I do a grep - it runs out of memory. Is there a way to
divide the file into 20 1 MB files so that I can search through it then?
Is there a better way to deal with this?
Thanks in advance,
Sara
2. need device: devices.pci.b7100010:devices.p
3. Cutting Up A File With Dynamic File Names
5. File - How to cut a file block by block ?
7. Help: How to cut last field by CUT command
8. KDevelop: how to create a library ??
9. tcp/ip communication blocs : getmsg hangs
10. How to bloc a web site ???
11. IPTABLES: bloc outgoing traffic individually possible?
12. cut and paste without temp file?
13. Cutting multiple lines from a text file