hi guys,
Suppose you have 100 files in a folder and you want to replace all occurances of a word say "ABCD" in those files with "DCBA", how would you do
it ???
jatin (13 Replies)
I used the following script
cd pathname
for y in `ls *`;
do sed "s/ABCD/DCBA/g" $y > temp; mv temp $y;
done
and it worked fine for finding and replacing strings with names etc. in all files of the given path.
I'm trying to replace a string which consists of path (location of file)
... (2 Replies)
i have to search a string and replace with multiple lines.
example
Input
echo 'sample text'
echo 'college days'
output
echo 'sample text'
echo 'information on students'
echo 'emp number'
echo 'holidays'
i have to search a word college and replace the multiple lines
i have... (1 Reply)
I used the following script
cd pathname
for y in `ls *`;
do sed "s/ABCD/DCBA/g" $y > temp; mv temp $y;
done
and it worked fine for finding and replacing strings with names etc. in all files of the given path.
I'm trying to replace a string which consists of path (location of file)
... (11 Replies)
find . -type f -name "*.sql" -print|xargs perl -i -pe 's/pattern/replaced/g'
this is simple logic to find and replace in multiple files & folders
Hope this helps.
Thanks
Zaheer (0 Replies)
Hi,
I am creating a script to do a find and replace single/multiple lines in a file with any number of lines.
I have written a logic in a script that reads a reference file say "findrep" and populates two variables $FIND and $REPLACE
print $FIND gives
Hi How r $u
Rahul()
Note:... (0 Replies)
Can someone tell me how I can do this?
e.g:
a=$(echo -e wert trewt ertert ertert ertert erttert
erterte
rterter
tertertert
ert)
How do i replace the STRING with $a?
I try this:
sed -i 's/STRING/'"$a"'/g' filename.ext
but this don' t work (2 Replies)
I have a list of files all over a file system e.g.
/home/1/foo/bar.x
/www/sites/moose/foo.txtI'm looking for strings in these files and want to replace each occurrence with a replacement string, e.g.
if I find: '#@!^\&@ in any of the files I want to replace it with: 655#@11, etc.
There... (2 Replies)
Hello Guys,
I need to replace a string with multiple lines.
For eg:-
ABC,DEF,GHI,JKL,MNO,PQR,STU
need to convert the above as below:-
ABC,DEF,
GHI1
GHI2
GHI3,
JKL,MNO,
PQR1
PQR2
PQR3,
STU
i have tried using code as:- (2 Replies)
Discussion started by: jassi10781
2 Replies
LEARN ABOUT SUNOS
setbuffer
setbuffer(3C) Standard C Library Functions setbuffer(3C)NAME
setbuffer, setlinebuf - assign buffering to a stream
SYNOPSIS
#include <stdio.h>
void setbuffer(FILE *iop, char *abuf, size_t asize);
int setlinebuf(FILE *iop);
DESCRIPTION
The setbuffer() and setlinebuf() functions assign buffering to a stream. The three types of buffering available are unbuffered, block
buffered, and line buffered. When an output stream is unbuffered, information appears on the destination file or terminal as soon as writ-
ten; when it is block buffered, many characters are saved and written as a block; when it is line buffered, characters are saved until
either a NEWLINE is encountered or input is read from stdin. The fflush(3C) function may be used to force the block out early. Normally all
files are block buffered. A buffer is obtained from malloc(3C) upon the first getc(3C) or putc(3C) performed on the file. If the standard
stream stdout refers to a terminal, it is line buffered. The standard stream stderr is unbuffered by default.
The setbuffer() function can be used after a stream iop has been opened but before it is read or written. It uses the character array abuf
whose size is determined by the asize argument instead of an automatically allocated buffer. If abuf is the null pointer, input/output
will be completely unbuffered. A manifest constant BUFSIZ, defined in the <stdio.h> header, tells how large an array is needed:
char buf[BUFSIZ];
The setlinebuf() function is used to change the buffering on a stream from block buffered or unbuffered to line buffered. Unlike set-
buffer(), it can be used at any time that the stream iop is active.
A stream can be changed from unbuffered or line buffered to block buffered by using freopen(3C). A stream can be changed from block
buffered or line buffered to unbuffered by using freopen(3C) followed by setbuf(3C) with a buffer argument of NULL.
RETURN VALUES
The setlinebuf() function returns no useful value.
SEE ALSO malloc(3C), fclose(3C), fopen(3C), fread(3C), getc(3C), printf(3C), putc(3C), puts(3C), setbuf(3C), setvbuf(3C)NOTES
A common source of error is allocating buffer space as an "automatic" variable in a code block, and then failing to close the stream in the
same block.
SunOS 5.10 13 May 1997 setbuffer(3C)