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
RFIO_OPEN(3)						      Rfio Library Functions						      RFIO_OPEN(3)

NAME
rfio_open - opens a file SYNOPSIS
#include <sys/types.h> #include "rfio_api.h" int rfio_open (const char *path, int flags, int mode); Under Linux, for large files: #define _LARGEFILE64_SOURCE #include <sys/types.h> #include "rfio_api.h" int rfio_open64 (const char *path, int flags, int mode); For large files, under other systems: #include <sys/types.h> #include "rfio_api.h" int rfio_open64 (const char *path, int flags, int mode); DESCRIPTION
rfio_open opens the file whose name is the string pointed to by path, a character string containing the filename specification, and asso- ciates a FILE stream with it. flags are formed by ORing the following values: O_RDONLY Open for reading only O_WRONLY Open for writing only O_RDWR Open for reading and writing O_NDELAY Do not block on open O_APPEND Append on each write O_CREAT Create file if it does not exist O_TRUNC Truncate size to 0 O_EXCL Error if create and file exists O_LARGEFILE When size can be superior to 2GB-1. See NOTES mode specifies the permission bits to be set if the file is created. Opening a file with O_APPEND set causes each write on the file to be appended to the end. If O_TRUNC is specified and the file exists, the file is truncated to zero length. If O_EXCL is set with O_CREAT, then if the file already exists, the open returns an error. This can be used to implement a simple exclusive access locking mechanism. If O_EXCL is set and the last component of the pathname is a symbolic link, the open will succeed even if the symbolic link points to an existing name. If the O_NDELAY flag is specified and the open call would result in the process being blocked for some reason (for example waiting for a carrier on a dial-up line), the open returns immediately. The first time the process attempts to perform IO on the open file, it will block (not currently implemented). On systems that support the Large Files, O_LARGEFILE in rfio_open allows files whose sizes cannot be represented in 31 bits to be opened. RETURN VALUE
If successful, returns a non-negative integer which may be used to refer to the file on subsequent rfio_write, rfio_read and rfio_close calls. On failure, rfio_open returns -1 and the error code is stored in serrno. ERRORS
ENOENT The named file/directory does not exist or is a null pathname. EACCES Search permission is denied on a component of the path prefix. EBUSY Device or resource busy. Happens if you try to open in write mode a LCG file that is in an active migration stream. EFAULT path is a NULL pointer. ENOTDIR A component of path prefix is not a directory. ENAMETOOLONG The length of path exceeds CA_MAXPATHLEN or the length of a path component exceeds CA_MAXNAMELEN. SENOSHOST Host unknown. SENOSSERV Service unknown. SECOMERR Communication error. SEE ALSO
Castor_limits(4),rfio_write(3),rfio_read(3),rfio_close(3) NOTES
On Irix, Tru64 and IA64 the 64 bit mode is the default one, open and open64 are identical. The flag O_LARGEFILE is accepted on Irix and IA64 (where it has no effect) but not on Tru64. On all other platforms, rfio_open with O_LARGEFILE is equivalent to a call to rfio_open64. AUTHOR
LCG Grid Deployment Team LCG
$Date: 2005/03/31 13:13:03 $ RFIO_OPEN(3)
All times are GMT -4. The time now is 06:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy