01-12-2012
Match EOF on newline in a file
Hi,
i have a file where the end-of-file might be at the end of of a valid text line or on a new line
case a)
p q r
s t u <eof>
case b)
p q r
s t u
<eof>
case c)
p q r
s t u
<no data, only carriage return>
<eof>
I have a requirement where <eof> line should not be read if it's on a newline (in a grep command)
I don't want to use tail -1 because that will omit data in case a), and
don't want to ignore blank lines because will lose the blank line after 's t u' in case c)
How do i do this?
Thanks,
-srinivas yelamanchili
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
Please help me on this.
how to check if the file DOES NOT have EOF ??
I am using ksh for this. (3 Replies)
Discussion started by: BasavarajaKC
3 Replies
2. Programming
Hi ,
I need to develop a parser which should match something like
1. text a=5 " a=20";
2. text a=..."
a=20";
3 text a=..."
a=20
b=34
c=12
";
I have used this regular expression in my Lex file to generate the tokens:
\".\s*.*\s.\" (8 Replies)
Discussion started by: vishwa787
8 Replies
3. Shell Programming and Scripting
Hi,
How to detect eof character in a data file? I am reading a data file generated from UNIX. I use java scanner, the scanner's hasNextLine() returns false in the middle of the file. I suspect there is a eof in the middle of the data file. Does anybody know how to check if a file contains eof... (1 Reply)
Discussion started by: redwing
1 Replies
4. UNIX for Dummies Questions & Answers
Hi everyone!
This is my very first post, sorry if I'm not posting in the right category.
I'm trying to match a newline "/n" using lex/yacc.
For example,
print(9,'\n',8)
should print
9
8
now do I write a regular expression to match exactly " '\n' "
Thanks! (1 Reply)
Discussion started by: code21
1 Replies
5. Shell Programming and Scripting
Hi ,
I am having an issue with the Awk script to insert newline for a regular expression match
Having a file like this
FILE1
####################
RXOER , RXERA , RXERC , RXERD
.RXEA(RXBSN), RXERD , REXCD
input RXEGT
buffer RXETRY
#######################
Want to match the RXE... (38 Replies)
Discussion started by: jaita
38 Replies
6. Shell Programming and Scripting
sed 's|^xyz.abc *= *.*|xyz.abc=60|' /test/myFile.properties > /test/myFile.properties1
myFile.properties has the last line as xyz.abc=23 does not end with newline.
When I run this command the last line is truncated if there is no newline character at EOF. Looking for an alternative here. (1 Reply)
Discussion started by: sunn_hps
1 Replies
7. Shell Programming and Scripting
Hi,
I ve a file with name "check"
in this file "check" has two lines with contents
now how to read these files line by line..
i used the code
But these doesnt stop with two lines.. So how to set condition that only two lines be read and the program should stop its execution.. Please... (5 Replies)
Discussion started by: Priya Amaresh
5 Replies
8. UNIX for Dummies Questions & Answers
Hi everyone
I have a file where CP occurs both within each line and at the very end:
dwer 17 knsdask= * CP hwla 17 h'wopie un CP
I would like to separate the line on the first CP to get:
dwer 17 knsdask= * CP
hwla 17 h'wopie un CP
What I have so far is:
awk '{for (x=1; x<NF; x++)
... (5 Replies)
Discussion started by: meet77
5 Replies
9. Shell Programming and Scripting
Greetings Experts,
I am in AIX; I have a file generated through awk after processing the input files. Now I need to replace or remove the new-line characters on all lines that doesn't have a ; which is the last character on the line. I tried to use sed 's/\n/ /g' After checking through the... (6 Replies)
Discussion started by: chill3chee
6 Replies
10. Shell Programming and Scripting
Hi
I'd like to add the newline:
\tuser: nobody", or "<TAB>user: nobody
to all files named:
docker-compose.ymlin subfolders of pwd with names beginning with 10-20.
Within these files, I'd like to find the line (there'll only be one) containing:
command: celery workerNOTE: As far as... (2 Replies)
Discussion started by: duncanbetts
2 Replies
GETS(3) Linux Programmer's Manual GETS(3)
NAME
fgetc, fgets, getc, getchar, gets, ungetc - input of characters and strings
SYNOPSIS
#include <stdio.h>
int fgetc(FILE *stream);
char *fgets(char *s, int size, FILE *stream);
int getc(FILE *stream);
int getchar(void);
char *gets(char *s);
int ungetc(int c, FILE *stream);
DESCRIPTION
fgetc() reads the next character from stream and returns it as an unsigned char cast to an int, or EOF on end of file or error.
getc() is equivalent to fgetc() except that it may be implemented as a macro which evaluates stream more than once.
getchar() is equivalent to getc(stdin).
gets() reads a line from stdin into the buffer pointed to by s until either a terminating newline or EOF, which it replaces with '