![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to reverse the contents of a file? | aajan | UNIX for Advanced & Expert Users | 10 | 05-17-2008 08:03 AM |
| How reverse cut or read rows of lines | doer | Shell Programming and Scripting | 16 | 07-18-2007 11:26 PM |
| Reverse Arrange File | The One | UNIX for Dummies Questions & Answers | 4 | 06-13-2007 08:57 AM |
| sort a file in reverse order | frustrated1 | Shell Programming and Scripting | 11 | 09-21-2005 12:41 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Need to read a file in reverse
I have to extract data from a text file which is huge in size >>10GB.
ie between two strings. If I do an ordinary sed it takes forever to come out. I was wondering if there was anyway to do the entire process in reverse and on finding the relevant string is there any way to break out of the search.. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
reading a file in reverse,
Code:
# !/usr/bin/ksh
linecnt=`wc -l file | awk '{print $1}'`
while [ $linecnt -ge 1 ]
do
sed -n "$linecnt"p file
linecnt=$(($linecnt - 1))
done
exit 0
|
|
#3
|
|||
|
|||
|
thanks man
thanks man!!
|
|
#4
|
||||
|
||||
|
Just for info: If you have GNU coreutils installed, you'll find the tac utility (reversed cat
Cheers ZB |
|
#5
|
||||
|
||||
|
From "HANDY ONE-LINERS FOR SED" ...
Code:
# reverse order of lines (emulates "tac") sed '1!G;h;$!d' # method 1 sed -n '1!G;h;$p' # method 2 |
|
#6
|
||||
|
||||
|
Similiar replies to a similiar post - sort a file in reverse order. I wonder how many use the search feature of the forum.
|
||||
| Google The UNIX and Linux Forums |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|