Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to read a file without opening the file and delete last line? Post 302897357 by alister on Sunday 13th of April 2014 03:01:15 PM
Old 04-13-2014
As bakunin stated, you cannot modify the contents of a file without opening it. The best you can do is open the file, find the penultimate newline character, and truncate to that positiion.

Regards,
Alister
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

delete file without opening vi

hi there guys, wonder if any gurus can help me out on this one... try searching the past threads but cant find anything. i have this huge file but when i use vi to open it it gives me the following error: <"pmrepserver.txt""/var/tmp/Ex86200" There is not enough space in the file... (7 Replies)
Discussion started by: lweegp
7 Replies

2. Shell Programming and Scripting

Urgent help required in deleting a line without opening a file usinga shell script

Hi, I need a help in deleting a line matching a particular pattern in a file using shell script without opening the file. The file is a .c/.cpp file. Is it possible? Thanks (6 Replies)
Discussion started by: naan
6 Replies

3. Shell Programming and Scripting

How to delete a particular text without opening the file.

Hi, Could someone tell me how to delete a particular text inside an existing file without opening the file? e.g. I have a text file called mytext.txt which contains three lines of text below and I want to delete “ ;” and delete the second line “b ;” including the carriage return. a ; b ; c ;... (12 Replies)
Discussion started by: stevefox
12 Replies

4. UNIX for Dummies Questions & Answers

Urgent help needed to delete some text without opening the file in unix

Hi To delete some text in 2 files in line1 ( not complete line) in unix without opening the files. For example: source file is like this <?xml version="1.0"... (5 Replies)
Discussion started by: pyaranoid
5 Replies

5. Shell Programming and Scripting

How to Delete string without opening a file

Hi Experts, I have several big size file arround 900 MB. From the file I need to delete some common strings but without opening the file. here is example- in file <?xml version='1.0' encoding='ISO-8859-1' standalone='no'?> <LogItems> <log logid="8423b5ae190810252359350480/1/1/1"> ... (6 Replies)
Discussion started by: thepurple
6 Replies

6. Shell Programming and Scripting

shell script to read a line in gps receiver log file and append that line to new file

Hi, I have gps receiver log..its giving readings .like below Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. GPSD,R=1 $GPGSV,3,1,11,08,16,328,40,11,36,127,00,28,33,283,39,20,11,165,00*71... (3 Replies)
Discussion started by: gudivada213
3 Replies

7. Shell Programming and Scripting

bash: read file line by line (lines have '\0') - not full line has read???

I am using the while-loop to read a file. The file has lines with null-terminated strings (words, actually.) What I have by that reading - just a first word up to '\0'! I need to have whole string up to 'new line' - (LF, 10#10, 16#A) What I am doing wrong? #make file 'grb' with... (6 Replies)
Discussion started by: alex_5161
6 Replies

8. Shell Programming and Scripting

echo ls to a file and then read file and selectively delete

I'm trying to write a script that will do an ls of a location, echo it into a file, and then read that file and selectively delete files/folders, so it would go something like this: cd $CLEAN_LOCN ls >>$TMP_FILE while read LINE do if LINE = $DONTDELETE skip elseif LINE =... (2 Replies)
Discussion started by: MaureenT
2 Replies

9. Shell Programming and Scripting

Read file line by line and process the line to generate another file

Hi, i have file which contains data as below(Only sample shown, it may contain more data similar to the one shown here) i need to read this file line by line and generate an output file like the one below i.e based on N value the number of MSISDNs will vary, if N=1 then the following... (14 Replies)
Discussion started by: aemunathan
14 Replies

10. Solaris

Getting read only propmt when opening /etc/system file

root@atrcx146:/# vi /etc/system "/var/tmp/Exv9a4Rb" Read-only file system Please let me know the reason (1 Reply)
Discussion started by: Marty11
1 Replies
inet_pton(3)						     Library Functions Manual						      inet_pton(3)

NAME
inet_pton - Converts a text string to a numeric address LIBRARY
Standard C Library (libc.so, libc.a) SYNOPSIS
#include <arpa/inet.h> int inet_pton ( int af, const char *src, void *dst) ; PARAMETERS
Specifies the address family. Valid values are AF_INET for an Internet Protocol Version 4 (IPv4) address and AF_INET6 for an IPv6 address. Points to the address text string to be converted. Points to a buffer that is to contain the numeric address. DESCRIPTION
The use of this routine is deprecated. Use the getaddrinfo(3) routine instead; it is also protocol-independent. The inet_pton() function converts a text string to a numeric value in Internet network-byte order. If the af parameter is AF_INET, the function accepts a string in the standard IPv4 dotted-decimal form: ddd.ddd.ddd.ddd In this format, ddd is a one to three digit decimal number between 0 and 255. If the af parameter is AF_INET6, the function accepts a string in the following form: x:x:x:x:x:x:x:x In this format, x is hexadecimal value of a 16-bit piece of the address. IPv6 addresses can contain long strings of zero (0) bits. To make it easier to write these addresses, you can use double colon characters (::) one time in an address to represent 1 or more 16-bit groups of zeros. For mixed IPv4 and IPv6 environments, the following form is also accepted: x:x:x:x:x:x:ddd.ddd.ddd.ddd In this form, x is hexadecimal value of a 16-bit piece of the address and ddd is a one to three digit decimal value between 0 and 255 that represents the IPv4 address. See RFC 2373 for more information on IPv6 addressing formats. The calling application is responsible for ensuring that the buffer referred to by the dst parameter is large enough to hold the numeric address. AF_INET addresses require 4 bytes and AF_INET6 addresses require 16 bytes. RETURN VALUES
Upon successful completion, the inet_pton() function returns 1. If the input string is not a valid IPv4 dotted-decimal string or a valid IPv6 address string, the function returns 0. If any other error occurs, the function returns -1. ERRORS
If the inet_pton() routine call fails, errno is set to one of the following values: The address family specified in the af parameter is unknown. RELATED INFORMATION
Functions: getaddrinfo(3), inet_ntop(3). RFC 2373, IP Version 6 Addressing Architecture delim off inet_pton(3)
All times are GMT -4. The time now is 08:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy