07-22-2009
add newline in file after finding specific text
Hi All,
I am tring to insert a newline with "/" in a text file whenever there is the text "end;"
right now I have inside file:
.
.
end;
I want to have:
.
.
end;
/
I tried doing the following within the file
:g/^end;/s//end; \/ /
but it is not putting the "/" on a new line. It is giving me instead
.
.
end; /
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi Everybody,
I need some help on formatting the files coming into unix box on the fly.
I get a file some thing like this in a single line.
ISA^M00^M ^M00^M ^M14^M006929681900 ^M01^M095449419 ... (5 Replies)
Discussion started by: ntekupal
5 Replies
2. Shell Programming and Scripting
hello i need some help here are the contents of my file.
test.txt
this is filename 1.mp3 http://www.url.com/filenamehashed
filename 2.mp3 http://www.url.com/fileamehashed
something_else.zip http://www.url.com/filenamehashed
so this file has 100 of these lines
filename url
I would... (9 Replies)
Discussion started by: mscice
9 Replies
3. UNIX for Dummies Questions & Answers
There is file named .htaccess. It is located in many directories on my web server. Instead of manually editing each file to add specific text, i thought there is possibly a command which will allow me to do that.
What i need to be done exactly?
In all .htaccess files i need to add/append the... (2 Replies)
Discussion started by: Boris_yo
2 Replies
4. Shell Programming and Scripting
Hi,
I have the following text file:
8 T1mapping_flip02 ok 128 108 30 1 665000-000008-000001.dcm
9 T1mapping_flip05 ok 128 108 30 1 665000-000009-000001.dcm
10 T1mapping_flip10 ok 128 108 30 1 665000-000010-000001.dcm
11 T1mapping_flip15 ok 128 108 30... (2 Replies)
Discussion started by: goodbenito
2 Replies
5. Shell Programming and Scripting
Hi All,
Just need small help in resolving the special new line character in generated output file.
In one of my shell script I am using following lines to get the spool file (i.e. sfile.txt) and
AAA_XXXX_p111_n222.txt
AAA_YYYY_p111_n222.txt
Here assuming
v_pnum="p111"
v_nid="n222"
... (1 Reply)
Discussion started by: shekharjchandra
1 Replies
6. UNIX for Dummies Questions & Answers
Good day ...
Well i do have this project in school, in our Principles Of Operating System Class
We are using Cygwin....
And our project goes like this...
Create a dictionary using cygwin. Display the following menu at the start of
execution
1-add a word in the dictionary # specify... (1 Reply)
Discussion started by: kpopfreakghecky
1 Replies
7. Shell Programming and Scripting
Good day ...
Well i do have this project in school, in our Principles Of Operating System Class
We are using Cygwin....
And our project goes like this...
Create a dictionary using cygwin. Display the following menu at the start of execution
1-add a word in the dictionary # specify the... (1 Reply)
Discussion started by: kpopfreakghecky
1 Replies
8. UNIX for Dummies Questions & Answers
Hello All,
this is my first post so I don't know if I am doing this right.
I would like to append entries from a series of strings (contained in a text file) consecutively at the end of specifically labeled lines in another file.
As an example:
- the file that contains the values to be... (3 Replies)
Discussion started by: gus74
3 Replies
9. Shell Programming and Scripting
Hi
This is my first post and I'm just a beginner. So please be nice to me.
I have a couple of html files where a pattern beginning with "http://www.site.com" and ending with "/resource.dat" is present on every 241st line. How do I extract this to a new text file?
I have tried sed -n 241,241p... (13 Replies)
Discussion started by: dejavo
13 Replies
10. Shell Programming and Scripting
What is the proper syntax to add specific text to a column in a file? Both the input and output below are tab-delineated. What if there are multiple text/fields, such as /CP&/2 /CM&/3 /AA&/4 Thank you :).
sed 's/*/Index&/1' del.txt.hg19_multianno.txt > matrix.del.txt (4 Replies)
Discussion started by: cmccabe
4 Replies
LEARN ABOUT FREEBSD
fgetln
FGETLN(3) BSD Library Functions Manual FGETLN(3)
NAME
fgetln -- get a line from a stream
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <stdio.h>
char *
fgetln(FILE *stream, size_t *len);
DESCRIPTION
The fgetln() function returns a pointer to the next line from the stream referenced by stream. This line is not a C string as it does not
end with a terminating NUL character. The length of the line, including the final newline, is stored in the memory location to which len
points. (Note, however, that if the line is the last in a file that does not end in a newline, the returned text will not contain a new-
line.)
RETURN VALUES
Upon successful completion a pointer is returned; this pointer becomes invalid after the next I/O operation on stream (whether successful or
not) or as soon as the stream is closed. Otherwise, NULL is returned. The fgetln() function does not distinguish between end-of-file and
error; the routines feof(3) and ferror(3) must be used to determine which occurred. If an error occurs, the global variable errno is set to
indicate the error. The end-of-file condition is remembered, even on a terminal, and all subsequent attempts to read will return NULL until
the condition is cleared with clearerr(3).
The text to which the returned pointer points may be modified, provided that no changes are made beyond the returned size. These changes are
lost as soon as the pointer becomes invalid.
ERRORS
[EBADF] The argument stream is not a stream open for reading.
The fgetln() function may also fail and set errno for any of the errors specified for the routines fflush(3), malloc(3), read(2), stat(2), or
realloc(3).
SEE ALSO
ferror(3), fgets(3), fgetwln(3), fopen(3), getline(3), putc(3)
HISTORY
The fgetln() function first appeared in 4.4BSD.
BSD
April 19, 1994 BSD