Sponsored Content
Top Forums Shell Programming and Scripting retain last 1000 line in a file Post 302420445 by methyl on Tuesday 11th of May 2010 04:28:39 PM
Old 05-11-2010
The approach will depend on the Operating System and the related tools, whether the file is currently open by a process (like syslogd), and whether it is a normal unix text file suitable for processing with shell tools.

Worth looking at the actual size of 1000 records because most versions of "tail" are limited in how much data they will buffer (you could for example ask for 1000 lines and only get 300).

If we assume that the file is a static normal unix text file and not open by another process, my first inclination would be to use "wc" to count the records then "sed" to output the required number of records to a temporary file.
This User Gave Thanks to methyl For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

retain Line numbers.. in Vi .. OR .. A SHELL SCRIPT

Hello everybody ! GOT SOMETHING INTERESTING... I am trying to retain line number for a text document.. usually we get line numbers in VI using :set nu , but I want to permanently store them. It's a 4000 lines of text and I want grep/search it for a list of words/fields stored in a different... (2 Replies)
Discussion started by: sdlayeeq
2 Replies

2. Shell Programming and Scripting

Command to add 1000 spaces to end of line

hi, could anyone tell me the command to append spaces at the end of the line. for example, i need 1000 spaces after the word "helloworld" echo "helloworld " i need to achieve this in someother way hardcoding 1000 spaces is not practical. as i am totally new... (3 Replies)
Discussion started by: kavithacs
3 Replies

3. UNIX for Dummies Questions & Answers

How to retain the header information of a file

Hi, I am using Bash shell to create some data and these data would be piped out to a file, let say output.txt. This output.txt I would like to add some extra header information such as comments, descriptions and general information on the text. I would like to know how could I maintain... (0 Replies)
Discussion started by: ahjiefreak
0 Replies

4. UNIX for Dummies Questions & Answers

Displays line number 1000 to 2000

Hi, I have 1 million records and want to extract lines betwen 10000 -20000 and put it in another file. Could you please suggest a command for this. Thanks in advance (3 Replies)
Discussion started by: unxusr123
3 Replies

5. Shell Programming and Scripting

Retain file permissions when saving .sh file from internet [OS X]

Hello. I have written a bash script that I am sharing with an OS X community I am a member of. The purpose of the script is to execute a series of commands for members without them having to get involved with Terminal, as it can be daunting for those with no experience of it at all. I have renamed... (4 Replies)
Discussion started by: baza210
4 Replies

6. Shell Programming and Scripting

Retain File Timestamp

There are directories of files that I have to run the dos2ux command on to get ride of the carriage return characters. Easy enough, but I have to retain the original timestamps on the files. I am thinking that I am going to have to strip off the timestamp for each file and convert it to unix time... (3 Replies)
Discussion started by: scotbuff
3 Replies

7. Shell Programming and Scripting

How to retain backslash in a line while reading a data file?

Hello Firends I have a file that contains data within single quotes, which has meaning of its own. When I am trying to parse through the file for a different functionality I noticed that I was loosing the backslash when occurrences in the file look like ('\0'). I would want to retain the... (3 Replies)
Discussion started by: easwam
3 Replies

8. UNIX for Dummies Questions & Answers

cat to a file but retain header

Hi, Is there a way to write to a txt file each day but retain the header on the file? I'm cat'ing 5 files into one .txt file each day but I want the new data to be written after the first 2 lines which are: Progname Size Date Owner ---------------------------- Basically I want my new... (4 Replies)
Discussion started by: Grueben
4 Replies

9. Shell Programming and Scripting

Adding a line to 1000's of files right after x amt of characters.

I am trying to add a single line of text to every file in a particular folder. There are thousands of files in the folder. Each file contains this same start of the first line: {d "%w- %d %m-, %Y - %T"} <some message here> with the rest of the text following the second curly bracket... (10 Replies)
Discussion started by: dlundwall
10 Replies

10. Shell Programming and Scripting

Creating a sequence of numbers in a line for 1000 files

Hi, I try to explain my problem , I have a file like this: aasdsaffsc23 scdsfsddvf46567 mionome0001.pdb asdsdvcxvds dsfdvcvc2324w What I need to do is to create 1000 files in which myname line listing a sequence of numbers from 0001 to 1000. So I want to have : nomefile0001.txt that must... (10 Replies)
Discussion started by: danyz84
10 Replies
scroll_lines(5) 						File Formats Manual						   scroll_lines(5)

NAME
scroll_lines - number of scrollable lines used by the Internal Terminal Emulator VALUES
Failsafe Default Allowed values Recommended values No larger than is sufficient for a user's purposes. DESCRIPTION
This tunable specifies the total number of scroll buffer lines used by the HP-UX graphics console Internal Terminal Emulator (ITE). This value is the sum of both on-screen and off-screen lines. For instance, if the ITE has 68 on-screen lines, and the value of scroll_lines is 128, then there will be 60 off-screen lines that can be scrolled back into view. During boot, the system may adjust the value of upward, depending upon the installed graphics hardware. On graphics cards capable of run- ning at more than one resolution, the ITE will first determine the maximum number of on-screen lines across all possible resolutions. The ITE will then ensure that is at least equal to this number of on-screen lines. For example, assume the graphics card supports two possible resolutions which result in one ITE resolution of 160 characters by 62 lines and another ITE resolution of 120 characters by 78 lines. If a value of 62 had been specified for in the system file, the ITE would then adjust this value upwards to 78. Who Is Expected to Change This Tunable? Anyone. Restrictions on Changing Changes to this tunable take effect at the next reboot. When Should the Value of This Tunable Be Raised? The value of can be increased if the user would like to retain additional lines in the scroll buffer. What Are the Side Effects of Raising the Value of This Tunable? Increasing the size of the ITE scroll buffer consumes kernel memory which will be dedicated to the ITE and cannot be used for other pur- poses by the rest of the system. Memory is used at the rate of 2 bytes per off-screen character. When Should the Value of This Tunable Be Lowered? If the additional off-screen lines in the scroll buffer are not required, can be decreased to free up a small amount of memory. The sav- ings will be two bytes per off-screen character. For instance, if the display is 160 characters wide, decreasing by 10 will free up 3200 bytes. What Are the Side Effects of Lowering the Value of This Tunable? If is set below or equal to the number of lines displayed on the ITE screen, no off-screen text will be accessible. What Other Tunables Should Be Changed at the Same Time? None. WARNINGS
All HP-UX kernel tunable parameters are release specific. This parameter may be removed or have its meaning changed in future releases of HP-UX. Installation of optional kernel software, from HP or other vendors, may cause changes to tunable parameter values. After installation, some tunable parameters may no longer be at the default or recommended values. For information about the effects of installation on tun- able values, consult the documentation for the kernel software being installed. For information about optional kernel software that was factory installed on your system, see at AUTHOR
was developed by HP. Tunable Kernel Parameters scroll_lines(5)
All times are GMT -4. The time now is 10:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy