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
AIBS(4) 						   BSD Kernel Interfaces Manual 						   AIBS(4)

NAME
aibs -- ASUSTeK AI Booster ACPI ATK0110 voltage, temperature and fan sensor SYNOPSIS
To compile this driver into the kernel, place the following lines in your kernel configuration file: device acpi device aibs Alternatively, to load the driver as a module at boot time, place the following lines in loader.conf(5): acpi_load="YES" aibs_load="YES" DESCRIPTION
The aibs driver provides support for the voltage, temperature and fan sensors available through the ATK0110 ASOC ACPI device on ASUSTeK moth- erboards. The number of sensors of each type, as well as the description of each sensor, varies according to the motherboard. The driver supports an arbitrary set of sensors, provides descriptions regarding what each sensor is used for, and reports the current values as well as the supposed range specifications of each sensor's input as defined by the motherboard manufacturer through ACPI. The range specifications are as follows: o Voltage sensors have a lower and an upper range specification. o Temperature sensors have two upper specifications. o Fan sensors may either have only the lower specification, or, depending on the DSDT, one lower and one upper specification. Sensor readings and the range specifications are made available through the sysctl(3) interface, and can be monitored with sysctl(8). For example, on an ASUS V3-P5G965 barebone: > sysctl dev.aibs.0.{volt,temp,fan} dev.aibs.0.volt.0: 1192 850 1600 dev.aibs.0.volt.1: 3312 2970 3630 dev.aibs.0.volt.2: 5017 4500 5500 dev.aibs.0.volt.3: 12302 10200 13800 dev.aibs.0.temp.0: 28.0C 80.0C 95.0C dev.aibs.0.temp.1: 55.0C 60.0C 95.0C dev.aibs.0.fan.0: 878 600 7200 dev.aibs.0.fan.1: 0 700 7200 > sysctl -d dev.aibs.0.{volt,temp,fan} dev.aibs.0.volt: dev.aibs.0.volt.0: Vcore Voltage dev.aibs.0.volt.1: +3.3 Voltage dev.aibs.0.volt.2: +5 Voltage dev.aibs.0.volt.3: +12 Voltage dev.aibs.0.temp: dev.aibs.0.temp.0: CPU Temperature dev.aibs.0.temp.1: MB Temperature dev.aibs.0.fan: dev.aibs.0.fan.0: CPU FAN Speed dev.aibs.0.fan.1: CHASSIS FAN Speed Generally, sensors provided by the aibs driver may also be supported by certain other drivers or utilities that access the ISA / LPC or I2C / SMBus devices directly. The precise collection of aibs sensors is comprised of the sensors specifically utilised in the motherboard design, which may be supported through a combination of one or more physical hardware monitoring chips. The aibs driver, however, provides the following advantages when compared to the native hardware monitoring drivers or other utilities: o Sensor values from aibs are expected to be more reliable. For example, voltage sensors in many hardware monitoring chips can only sense voltage from 0 to 2 or 4 volts, and the excessive voltage is removed by the resistors, which may vary with the motherboard and with the voltage that is being sensed. In aibs, the required resistor factors are provided by the motherboard manufacturer through ACPI; in the native drivers, the resistor factors are encoded into the driver based on the chip manufacturer's recommendations. In essence, sensor values from aibs are very likely to be identical to the readings from the Hardware Monitor screen in the BIOS. o Sensor descriptions from aibs are more likely to match the markings on the motherboard. o Sensor range specifications are supported by aibs. The range specification is reported for each individual sensor as suggested by the motherboard manufacturer. For example, the threshold for the CPU temperature sensor is likely to be significantly higher than that for the chassis temperature sensor. o Support for newer chips in aibs. Newer chips may miss a native driver, but should be supported through aibs regardless. SEE ALSO
sysctl(3), acpi(4), sysctl(8) HISTORY
The aibs driver first appeared in OpenBSD 4.7, DragonFly 2.5, NetBSD 6.0 and FreeBSD 9.0. An earlier version of the driver, acpi_aiboost, first appeared in FreeBSD 7.0 and NetBSD 5.0. AUTHORS
The aibs driver was written for OpenBSD, DragonFly, NetBSD and FreeBSD by Constantine A. Murenin <cnst@FreeBSD.org>, Raouf Boutaba Research Group, David R. Cheriton School of Computer Science, University of Waterloo. An earlier version of the driver, named acpi_aiboost, was written for FreeBSD by Takanori Watanabe. BSD
April 4, 2010 BSD
All times are GMT -4. The time now is 07:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy