Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Want to remove all lines but not latest 50 lines from a file Post 302868165 by targzeta on Saturday 26th of October 2013 08:48:02 AM
Old 10-26-2013
@Scrutinizer, @Don Cragun and @alister. You have reason.
Code:
$> strace sed -ni '2,$p' file
....
open("file", O_RDONLY)                  = 3
...
open("./sedvS2Dny", O_RDWR|O_CREAT|O_EXCL, 0600) = 4
...
write(4, "SIsxCwUouy\n", 11)            = 11
write(4, "qWngJUOkrc\n", 11)            = 11
...
rename("./sedvS2Dny", "file")           = 0
...

Emanuele
 

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
SHM_OPEN(2)						      BSD System Calls Manual						       SHM_OPEN(2)

NAME
shm_open, shm_unlink -- shared memory object operations LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <sys/types.h> #include <sys/mman.h> int shm_open(const char *path, int flags, mode_t mode); int shm_unlink(const char *path); DESCRIPTION
The shm_open() system call opens (or optionally creates) a POSIX shared memory object named path. The flags argument contains a subset of the flags used by open(2). An access mode of either O_RDONLY or O_RDWR must be included in flags. The optional flags O_CREAT, O_EXCL, and O_TRUNC may also be specified. If O_CREAT is specified, then a new shared memory object named path will be created if it does not exist. In this case, the shared memory object is created with mode mode subject to the process' umask value. If both the O_CREAT and O_EXCL flags are specified and a shared memory object named path already exists, then shm_open() will fail with EEXIST. Newly created objects start off with a size of zero. If an existing shared memory object is opened with O_RDWR and the O_TRUNC flag is spec- ified, then the shared memory object will be truncated to a size of zero. The size of the object can be adjusted via ftruncate(2) and queried via fstat(2). The new descriptor is set to close during execve(2) system calls; see close(2) and fcntl(2). As a FreeBSD extension, the constant SHM_ANON may be used for the path argument to shm_open(). In this case, an anonymous, unnamed shared memory object is created. Since the object has no name, it cannot be removed via a subsequent call to shm_unlink(). Instead, the shared memory object will be garbage collected when the last reference to the shared memory object is removed. The shared memory object may be shared with other processes by sharing the file descriptor via fork(2) or sendmsg(2). Attempting to open an anonymous shared memory object with O_RDONLY will fail with EINVAL. All other flags are ignored. The shm_unlink() system call removes a shared memory object named path. RETURN VALUES
If successful, shm_open() returns a non-negative integer, and shm_unlink() returns zero. Both functions return -1 on failure, and set errno to indicate the error. COMPATIBILITY
The path argument does not necessarily represent a pathname (although it does in most other implementations). Two processes opening the same path are guaranteed to access the same shared memory object if and only if path begins with a slash ('/') character. Only the O_RDONLY, O_RDWR, O_CREAT, O_EXCL, and O_TRUNC flags may be used in portable programs. The result of using open(2), read(2), or write(2) on a shared memory object, or on the descriptor returned by shm_open(), is undefined. It is also undefined whether the shared memory object itself, or its contents, persist across reboots. In FreeBSD, read(2) and write(2) on a shared memory object will fail with EOPNOTSUPP and neither shared memory objects nor their contents persist across reboots. ERRORS
The following errors are defined for shm_open(): [EINVAL] A flag other than O_RDONLY, O_RDWR, O_CREAT, O_EXCL, or O_TRUNC was included in flags. [EMFILE] The process has already reached its limit for open file descriptors. [ENFILE] The system file table is full. [EINVAL] O_RDONLY was specified while creating an anonymous shared memory object via SHM_ANON. [EFAULT] The path argument points outside the process' allocated address space. [ENAMETOOLONG] The entire pathname exceeded 1023 characters. [EINVAL] The path does not begin with a slash ('/') character. [ENOENT] O_CREAT is specified and the named shared memory object does not exist. [EEXIST] O_CREAT and O_EXCL are specified and the named shared memory object dies exist. [EACCES] The required permissions (for reading or reading and writing) are denied. The following errors are defined for shm_unlink(): [EFAULT] The path argument points outside the process' allocated address space. [ENAMETOOLONG] The entire pathname exceeded 1023 characters. [ENOENT] The named shared memory object does not exist. [EACCES] The required permissions are denied. shm_unlink() requires write permission to the shared memory object. SEE ALSO
close(2), ftruncate(2), fstat(2), mmap(2), munmap(2) STANDARDS
The shm_open() and shm_unlink() functions are believed to conform to IEEE Std 1003.1b-1993 (``POSIX.1''). HISTORY
The shm_open() and shm_unlink() functions first appeared in FreeBSD 4.3. The functions were reimplemented as system calls using shared mem- ory objects directly rather than files in FreeBSD 7.0. AUTHORS
Garrett A. Wollman <wollman@FreeBSD.org> (C library support and this manual page) Matthew Dillon <dillon@FreeBSD.org> (MAP_NOSYNC) BSD
March 20, 2007 BSD
All times are GMT -4. The time now is 05:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy