Sponsored Content
Full Discussion: edit sed command
Top Forums Shell Programming and Scripting edit sed command Post 302648197 by Corona688 on Tuesday 29th of May 2012 11:54:38 AM
Old 05-29-2012
Of course it "stalls", it has to read 9 whole gigs of data before it can do anything else and tries to keep the entire 500,000 lines of data in memory at once. Processing 9 gigs of data is going to take a while no matter how you cut it, and it won't find the data it wants until it's nearly done. To get the last 500,000 lines, it has to figure out where the end is, then back up from there...

Some implementations of 'tac' however, work by seeking, which would avoid having to read the first 99% of the file. It'd deliver them in reverse order so you could just head to get the number of lines you want, then reverse it again. I'm not sure Sun's does, but it's worth a shot:

Code:
tac filename | head -n 500000 > /tmp/$$
tac /tmp/$$ > /tmp/$$-forward
rm -f /tmp/$$

If Sun's tac doesn't do that, maybe you can install GNU tac.

Last edited by Corona688; 05-29-2012 at 01:00 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

edit file using sed (not create another!)

Hi, I generally use Perl for this ex. perl -e 's/pattern/replace/g' -p -i <filename> I did something like this.. find . -type f -exec perl -e 's/pattern/replace/g' -p -i {} \; I want to do this with "sed" but what I get is the output being printed on the screen.. i can do sed... (3 Replies)
Discussion started by: oldtrash
3 Replies

2. Shell Programming and Scripting

Simple SED edit

I have output like the following: B D 20070116095820001 N D S0000579.LOG S0000582.LOG B D 20070116095750001 N D S0000574.LOG S0000576.LOG B D 20070116095734001 N D S0000570.LOG S0000573.LOG B D 20070116095705001 N D S0000569.LOG S0000569.LOG B D ... (5 Replies)
Discussion started by: rdudejr
5 Replies

3. Shell Programming and Scripting

SED text edit help needed

Could someone please tell me how to delete all lines above a line which contains a particular string? (possibly using SED command) I know how to do this if the target string appears in only one line of file but when it appears in multiple lines it only deletes from the first line which the string... (3 Replies)
Discussion started by: stevefox
3 Replies

4. Shell Programming and Scripting

sed command to edit fields

Hi, I'm a newbie to sed and I'm having trouble working with sed and fields. Suppose I have a text file with: AAA RFG:$2.10:6:25Oct06 WDD GGTR:$3.50:5:25Oct06 ADDSJ OO:$1.37:3:26Oct07 UGBDN S:$4.73:1:27Oct06 USY ADC:$2.38:20:27Oct06 And I want to substitute field 2 of line 3 with, say,... (3 Replies)
Discussion started by: aloe_vera
3 Replies

5. Shell Programming and Scripting

File edit with awk or sed

I have the follwoing file: This looks to be : seperated. For the first field i want only the file name without ".txt" and also i want to remove "+" sign if the second field starts with "+" sign. Input file: Output file: Appreciate your help (9 Replies)
Discussion started by: pinnacle
9 Replies

6. Shell Programming and Scripting

Conditional edit for a field using sed

Hi I want to repalce a field in a txt file on solaris with say 100 records and each record having a total of 10 fields separated by a ~ . based on the following condition the record should be edited or else the record should be written as it is to a if the seventh field is 'XX' and if... (2 Replies)
Discussion started by: acharania2011
2 Replies

7. Shell Programming and Scripting

Sed or Awk or both to edit file

What is an efficient way to remove all lines from the input file which contain a file name? inputfile: ======================= # comment # comment # comment 5 8 10 /tmp 5 8 10 /var/run 5 8 10 /etc/vfstab 5 8 9 /var/tmp 5 8 10 /var/adm/messages... (7 Replies)
Discussion started by: Arsenalman
7 Replies

8. Shell Programming and Scripting

sed edit in place -i issues

Hello, I am attempting to create a command that I can eventually put into a loop so I can edit 1file on many servers. I would like to edit the file in place with sed -i. If not I will take any suggestions on how to use a temp file. I need to remove a email address from the configuration file... (4 Replies)
Discussion started by: abacus
4 Replies

9. UNIX for Dummies Questions & Answers

sed to edit nth filed

Hi all, I want to edit nth filed of a comma delimited line with some value. Can I use sed command to do this. Pls suggest me the command here. Thanks, Poova. (2 Replies)
Discussion started by: poova
2 Replies

10. Shell Programming and Scripting

Inline edit using sed / awk

Hi, I have file with all the lines as following format <namebindings:StringNameSpaceBinding xmi:id="StringNameSpaceBinding" name="ENV_CONFIG_PATH" nameInNameSpace="COMP/HOD/MYSTR/BACKOFFICE/ENV_CONFIG_PATH" stringToBind="test"/> I want to replace (all the lines) value of... (8 Replies)
Discussion started by: shuklaa02
8 Replies
TAC(1)								   User Commands							    TAC(1)

NAME
tac - concatenate and print files in reverse SYNOPSIS
tac [OPTION]... [FILE]... DESCRIPTION
Write each FILE to standard output, last line first. With no FILE, or when FILE is -, read standard input. Mandatory arguments to long options are mandatory for short options too. -b, --before attach the separator before instead of after -r, --regex interpret the separator as a regular expression -s, --separator=STRING use STRING as the separator instead of newline --help display this help and exit --version output version information and exit AUTHOR
Written by Jay Lepreau and David MacKenzie. REPORTING BUGS
Report bugs to <bug-coreutils@gnu.org>. COPYRIGHT
Copyright (C) 2006 Free Software Foundation, Inc. This is free software. You may redistribute copies of it under the terms of the GNU General Public License <http://www.gnu.org/licenses/gpl.html>. There is NO WARRANTY, to the extent permitted by law. SEE ALSO
The full documentation for tac is maintained as a Texinfo manual. If the info and tac programs are properly installed at your site, the command info tac should give you access to the complete manual. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +--------------------+--------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +--------------------+--------------------+ |Availability | SUNWgnu-coreutils | +--------------------+--------------------+ |Interface Stability | Uncommitted | +--------------------+--------------------+ NOTES
Source for GNU coreutils is available on http://opensolaris.org. tac 6.7 December 2006 TAC(1)
All times are GMT -4. The time now is 06:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy