Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Reading specific part of file Post 76712 by guptan on Thursday 30th of June 2005 04:55:11 AM
Old 06-30-2005
Reading specific part of file

I have a requirement to go to particular line in the file and from there read the contents till it meets a particular criteria. For eg if the contents of the file is like

81 abcd ------------------- Line 1
82 cdfe ------------------- Line 2
83 dfj ------------------- Line 3
84 df ------------------- Line 4
81 dkfh ------------------- Line 5
82 df ------------------- Line 6
83 dlf ------------------- Line 7
84 dif ------------------- Line 8
81 sdfh ------------------- Line 9
82 dfjh ------------------- Line 10
83 kdf ------------------- Line 11
84 dfj ------------------- Line 12

What the program should do is go to line number 5 directly and from there read the contents of the file till it finds the line starting with 81 again.

TIA
Narayana Gupta
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

reading specific line from file

Hi all... I not a expert unix script programmer, Kindly adjust. My requirement is that, i have a file which contains the about 10 lines - say 1 2 3 ... 8 war of the worlds: => text in this line 9 9000,80,78,77,334,445 => this line contains some numbers separted by commas 10 ... (10 Replies)
Discussion started by: cool_boss2121
10 Replies

2. Shell Programming and Scripting

Reading data from a specific line in a text file

hello, I have got the following problem that I am hoping someone can help with please. 1. I have got the following text file (below) , the columns data are 'Test Day', 'Board', 'Betting Number'. TEXT FILE ============================================ 1 3 02-01-27-28-29-30 0 1... (1 Reply)
Discussion started by: jermaine4ever
1 Replies

3. Shell Programming and Scripting

Reading data from a specific line in a text file

Hello, I have a problem which is giving me headache for days, can some please help. Please see code and text fiel below. Please see text in red for the problem I am facing # Program gets an input x from user while read line ; do echo... (4 Replies)
Discussion started by: jermaine4ever
4 Replies

4. UNIX and Linux Applications

Reading a file for specific words

Hi I have a script where the user calls it with arguments like so: ./import.sh -s DNSNAME -d DBNAME I want to check that the database entered is valid by going through a passwd.ds file and checking if the database exists there. If it doesn't, the I need to send a message to my log... (4 Replies)
Discussion started by: ladyAnne
4 Replies

5. UNIX for Dummies Questions & Answers

Reading a specific line from a file

Hi All, I am having 100 lines a text file say a.txt. I want read the 'nth' line from that file inside a script. Kindly tell us how to that. (2 Replies)
Discussion started by: boopathyvasagam
2 Replies

6. Shell Programming and Scripting

Help with reading a specific portion of a file using PERL

Hello, I am trying to read from a file using PERL:confused, however i need to read specific portions of the file the file goes like this <Name 1 Hono <Name 2 Jack and so on anyways i need to be able to write a program that ONLY opens the lines beginning with "<"? so it would... (2 Replies)
Discussion started by: UNDstudent
2 Replies

7. UNIX for Dummies Questions & Answers

Reading specific lines from a file using index or keywords

Hello I want to read from a file which contains email addresses. The file format is like this. from@mail.com to1@mail.com to2@mail.com cc@mail.com bcc@mail.com I'll have to read from such file and assign the email addresses to respective variables. frommail =... (11 Replies)
Discussion started by: Kyaw Lwin Phyo
11 Replies

8. Shell Programming and Scripting

[Solved] Printing a part of the last line of the specific part of a file

Hi, I have 80 large files, from which I want to get a specific value to run a Bash script. Firstly, I want to get the part of a file which contains this: Name =A xxxxxx yyyyyy zzzzzz aaaaaa bbbbbb Value = 57 This is necessary because in a file there are written more lines which... (6 Replies)
Discussion started by: wenclu
6 Replies

9. Shell Programming and Scripting

Reading specific range of columns in an Excel file

Hi All, I want to read an excel file. PFA excel, I want to read the cloumn from A to G and the V to AH starting from Row number 3. Please help me on this. (7 Replies)
Discussion started by: Abhisrajput
7 Replies

10. Shell Programming and Scripting

How to print the specific part of the file name with file creation date?

Hello Folks, I have an requirement, where i need to get total count of the file based on creation date with there filename selected pattern. Filename: MobileProtocol.20171228T154200.157115.udr I want to get the count of files created on each day based on a pattern find. find . -type... (7 Replies)
Discussion started by: sadique.manzar
7 Replies
FGETWS(3)						   BSD Library Functions Manual 						 FGETWS(3)

NAME
fgetws -- get a line of wide characters from a stream LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <stdio.h> #include <wchar.h> wchar_t * fgetws(wchar_t * restrict ws, int n, FILE * restrict fp); DESCRIPTION
The fgetws() function reads at most one less than the number of characters specified by n from the given fp and stores them in the wide-char- acter string ws. Reading stops when a newline character is found, at end-of-file or error. The newline, if any, is retained. If any char- acters are read and there is no error, a '' character is appended to end the string. RETURN VALUES
Upon successful completion, fgetws() returns ws. If end-of-file occurs before any characters are read, fgetws() returns NULL and the buffer contents remain unchanged. If an error occurs, fgetws() returns NULL and the buffer contents are indeterminate. The fgetws() function does not distinguish between end-of-file and error, and callers must use feof(3) and ferror(3) to determine which occurred. ERRORS
[EBADF] The given fp argument is not a readable stream. [EILSEQ] The data obtained from the input stream does not form a valid multibyte character. The function fgetws() may also fail and set errno for any of the errors specified for the routines fflush(3), fstat(2), read(2), or malloc(3). SEE ALSO
feof(3), ferror(3), fgets(3) STANDARDS
The fgetws() function conforms to IEEE Std 1003.1-2001 (``POSIX.1''). BSD
August 6, 2002 BSD
All times are GMT -4. The time now is 01:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy