Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Want to remove all lines but not latest 50 lines from a file Post 302868217 by alister on Saturday 26th of October 2013 03:24:17 PM
Old 10-26-2013
In-place move to the top of the file of the final 5 lines without using any variables or temp files:
Code:
dd if=/dev/null of=fname bs=1 seek=$(tail -n5 fname | tee >(wc -c) 1<>fname)

Note: The process substitution implementations I've seen require either /dev/fd or named pipes. If /dev/fd isn't available, and if the shell cannot create the fifo in its usual temp dir, the shell may need to be informed of a suitable alternative location.

Regards,
Alister

Last edited by alister; 10-26-2013 at 06:26 PM.. Reason: Corrected text to match tail's five line count
These 3 Users Gave Thanks to alister For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

remove lines from file

file: 1 xxxxxxx 2 xxx xxx 5 xxx xxx ... 180 xxxxxx 200 xxx how to remove any lines with the first number range 1-180 (9 Replies)
Discussion started by: bluemoon1
9 Replies

2. Shell Programming and Scripting

To remove the lines in my file

Hi, There seems to some hack attempts in my site. I have attached the index page of my site and I need to remove the below lines from the index page. The below lines are at the center of the file. --> </style> <script>E V A L( unescape(... (5 Replies)
Discussion started by: gsiva
5 Replies

3. UNIX for Dummies Questions & Answers

vi to remove lines in file

All, I have a text file with several entries like below: personname personname.domain.com I know there is a way to use vi to remove only the personname.domain.com line. Can someone help? I believe that it involves /s/g/ something...I just can't remember the exact syntax. Thanks (2 Replies)
Discussion started by: kjbaumann
2 Replies

4. Shell Programming and Scripting

remove lines from file

Hi gurus, i'm trying to remove a number of lines from a large file using the following command: sed '1,5000d' oldfile > newfile Somehow the lines in the old file are not deleted... Am I doing this wrongly? Any suggestions? :confused: Thanks! :) wee (10 Replies)
Discussion started by: lweegp
10 Replies

5. Shell Programming and Scripting

remove : lines from file

A small question I have a test.txt file I have contents as: a:google b:yahoo : c:facebook : d:hotmail How do I remove the line with : my output should be a:google b:yahoo c:facebook d:hotmail (5 Replies)
Discussion started by: aronmelon
5 Replies

6. Shell Programming and Scripting

remove blank lines and merge lines in shell

Hi, I'm not a expert in shell programming, so i've come here to take help from u gurus. I'm trying to tailor a csv file that i got to make it work for the LOAD FROM command. I've a datatable csv of the below format - --in file format xx,xx,xx ,xx , , , , ,,xx, xxxx,, ,, xxx,... (11 Replies)
Discussion started by: dvah
11 Replies

7. Shell Programming and Scripting

Remove lines from file

Hey Gang- I have a list of servers. I want to exclude servers that begin with and end with certain characters. Is there an easy command to do this? Example wvm1234dev wvm1234pro uvm1122dev uvm1122bku uvm1344dev I want to exclude any lines that start with "wvm" OR "uvm" AND end... (7 Replies)
Discussion started by: idiotboy
7 Replies

8. Shell Programming and Scripting

Two files, remove lines from second based on lines in first

I have two files, a keepout.txt and a database.csv. They're unsorted, but could be sorted. keepout: user1 buser3 anuser19 notheruser27 database: user1,2343,"information about",field,blah,34 user2,4231,"mo info",etc,stuff,43 notheruser27,4344,"hiya",thing,more thing,423... (4 Replies)
Discussion started by: esoffron
4 Replies

9. Shell Programming and Scripting

Remove lines that are subsets of other lines in File

Hello everyone, Although it seems easy, I've been stuck with this problem for a moment now and I can't figure out a way to get it done. My problem is the following: I have a file where each line is a sequence of IP addresses, example : 10.0.0.1 10.0.0.2 10.0.0.5 10.0.0.1 10.0.0.2... (5 Replies)
Discussion started by: MisterJellyBean
5 Replies

10. Shell Programming and Scripting

awk to remove lines that do not start with digit and combine line or lines

I have been searching and trying to come up with an awk that will perform the following on a converted text file (original is a pdf). 1. Since the first two lines are (begin with) text they are removed 2. if $1 is a number then all text is merged (combined) into one line until the next... (3 Replies)
Discussion started by: cmccabe
3 Replies
jfs_fscklog(8)						   Extract/Display JFS fsck Log 					    jfs_fscklog(8)

NAME
jfs_fscklog - extract a JFS fsck service log into a file and/or format and display the extracted file SYNOPSIS
jfs_fscklog [ -d ] [ -e device ] [ -f output.file ] [ -p ] [ -V ] DESCRIPTION
jfs_fscklog with option -e device extracts the contents of either the most recent or immediately prior (specified with option -p) JFS fsck service log from the specified device, and writes the output to a file. The file name may be specified with the -f option, or the default file name is <pwd>fscklog.new. If the -p option is used, the default file name is <pwd>fscklog.old. jfs_fscklog with option -d formats and displays the contents of the extracted file. jfs_fscklog with options -d and -e device extracts and displays the JFS fsck service log. OPTIONS
-d Format and display a previously extracted JFS fsck service log. -e device Extract the JFS fsck service log from device and store it in a file. (device is the special file name corresponding to the actual device from which the fsck log will be extracted (e.g. /dev/hdb1 )). -f file.name Specify the file name, overriding the default file name. When used with -e device, file.name specifies the name of the file into which the JFS fsck log will be extracted. When used with -d, file.name specifies the name of the extracted file whose contents will be formatted and displayed. file.name must be 127 characters or less in length. file.name will be created in the present working directory unless it is fully qualified. -p Extract the prior log (as opposed to the most recent log). -V Print version information and exit (regardless of any other chosen options). EXAMPLES
Extract the most recent JFS fsck log on /dev/hda5 into <pwd>fscklog.new: jfs_fscklog -e /dev/hda5 Extract the most recent JFS fsck log on /dev/hdb3 into /temp/l9651107.log: jfs_fscklog -e /dev/hdb3 -f /temp/l9651107.log Display the JFS fsck log that was extracted into /temp/l9651107.log: jfs_fscklog -d -f /temp/l9651107.log Extract and display the previous JFS fsck log from /dev/hda8: jfs_fscklog -e /dev/hda8 -d -p REPORTING BUGS
If you find a bug in JFS or jfs_fscklog, please report it via the bug tracking system ("Report Bugs" section) of the JFS project web site: http://jfs.sourceforge.net/ Please send as much pertinent information as possible, including any jfs_fscklog error messages and the complete output of running jfs_fsck with the -v option on the JFS device. SEE ALSO
jfs_fsck(8), jfs_mkfs(8), jfs_tune(8), jfs_logdump(8), jfs_debugfs(8) AUTHOR
Barry Arndt (barndt@us.ibm.com) jfs_fscklog is maintained by IBM. See the JFS project web site for more details: http://jfs.sourceforge.net/ October 28, 2002 jfs_fscklog(8)
All times are GMT -4. The time now is 10:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy