Is the block of code the only block that starts <?php and finishes ?>? I suspect that maybe there are other blocks that start and end this way, but on the off chance that this will be the only block like this, then this sed should work:
It deletes all lines between the starting line with "<?php" and the ending "?>" line as it reads the file. The updated file is written to $file.
If you can use this sed, just replace it in the earlier example.
If there are more than one php blocks of code, then you'll need to find a unique string inside the block that you want to delete. Change the one line in the script below that has "/enter your nickname/" to contain the unique string from the block of code and it should find and delete the lines containing the string.
Hope this helps get you going.
Last edited by agama; 03-04-2012 at 01:44 PM..
Reason: corrected comment that introduced a bug
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 V7
wrjpgcom
wrjpgcom(1) User Commands wrjpgcom(1)NAME
wrjpgcom - insert text comments into a JPEG file
SYNOPSIS
wrjpgcom [-replace] [-comment text] [-cfile name] [filename]
DESCRIPTION
wrjpgcom reads the named JPEG or JFIF file, or the standard input if no file is named, and generates a new JPEG or JFIF file on the stan-
dard output. A comment block is added to the file.
The JPEG standard allows "comment" (COM) blocks to occur within a JPEG file. Although the standard does not actually define the intended
function of COM blocks, they are widely used to hold user-supplied text strings. This enables you to add annotations, titles, index terms,
and so on to your JPEG files, and later retrieve the COM blocks as text. COM blocks do not interfere with the image stored in the JPEG
file. The maximum size of a COM block is 64K, but you can have many COM blocks in one JPEG file.
wrjpgcom adds a COM block, containing text that you provide, to a JPEG file. Ordinarily, the COM block is added after any existing COM
blocks, but you can delete the old COM blocks if you wish.
OPTIONS
The following options are supported:
-cfile name Read the text for a new COM block from the named file.
-comment text Supply the text for a new COM block on the command line.
-replace Delete any existing COM blocks from the file.
OPERANDS
The following operands are supported:
filename The name of the JPEG file to which you want to add text comments.
EXTENDED DESCRIPTION
To add only one line of comment text, use the -comment option to provide the text on the command line. Specify the comment text within
quotes, so that the text is treated as a single argument. Longer comments can be read from a text file.
If you specify neither the -comment nor the -cfile option, wrjpgcom reads the comment text from standard input. In such cases, you must
supply an input image filename. You can enter multiple lines, up to 64KB. Type an end-of-file indicator, usually Ctrl-D, to terminate the
comment text entry.
wrjpgcom does not add a COM block if the provided comment string is empty. Therefore, you can use -replace -comment "" to delete all COM
blocks from a file.
EXAMPLES
Example 1: Adding a Short Comment to in.jpg to Produce out.jpg
example% wrjpgcom -c "View of my back yard" in.jpg > out.jpg
Example 2: Attaching a Long Comment Previously Stored in comment.txt
example% wrjpgcom in.jpg < comment.txt > out.jpg
or
example% wrjpgcom -cfile comment.txt < in.jpg > out.jpg
In this example, 1000 is a number that is larger than the number of rows in the source file.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWjpg |
+-----------------------------+-----------------------------+
|Interface stability |External |
+-----------------------------+-----------------------------+
SEE ALSO cjpeg(1), djpeg(1), jpegtran(1), rdjpgcom(1)NOTES
This man page was originally written by the Independent JPEG Group. Updated by Breda McColgan, Sun Microsystems Inc., 2004.
SunOS 5.10 26 Mar 2004 wrjpgcom(1)