I have nearly 100 HTML files that uses the <tt> tag to markup inline code which I'd like to change to the more meaningful <code> tag. I was thinking of doing something on the order of a massive sed -i 's/<tt>/<code>/g' command but I'm curious if there's a more appropriate industrial mechanism for changing tag types on a large HTML tree...
How can I iterate over multi-line regexp matches using sed and bash?
I'm trying to generate some quick docs from comments in a file, like so:
/**
* @name myFun
* @return {int}
*/
I can extract every comment block using sed -n -e '/\/\*\*$/,/\*\/$/p', but now I'd like to stuff each match into a bash array so I can parse the details ...
i have following pattern
parts=/a,1mb,/b/c,2gb,/zee/last,-1 #general form on next line
^parts=path1,size1,...,lastPath,-1$
I want to replace all $path1,$size1 except $lastplace,-1 with $newPath,$newSize i.e.
parts_new=/p,2mb,/q/r,5gb,/zee/last,-1 #general on next line
^parts=newPathX,newSizeX,lastPath,-1$
I figured how to do it usi...
I want to remove all the text between (and including) two strings in all the files in a directory. For an example, the files look something like this:
flag
bla bla bal
bla bla bla
endflag
etc..
This is what I'm doing with sed:
sed -i "s:flag.*endflag::m" *
However, the 'm' option is not part of sed. All the other Stack Overflow th...
Hi,
I want to print next line of matching word with sed.
I tried this command but it gives error :
sed -n '/<!\[CDATA\[\]\]>/ { N p}/' test.xml
...
I've just come off the Winows wagon, and the gnome-terminal and bash are looking great, but I don't quite know how to get it to do what I want, (I suspect it is possible).
Can std output (eg. from sed) be made to run as a command?
(ie. interpret and run the output as part of the script's logic.)
I am polling a process to output its sta...
Hi All,
I have a text file containing ~300k rows. Each row has a varying number of comma-delimited fields, the last of which is guaranteed numerical. I want to sort the file by this last numerical field. I can't do:
sort -t, -n -k 2 file.in > file.out
as the number of fields in each row is not constant. I think sed, awk maybe the ans...
I do not want to install another plugin, like pylint.vim,
And today, I decide to use vim edit python instead of pydev which is a eclipse plugin. But I got issues.
I have add this in my vimrc
autocmd BufWritePost *.py !pylint <afile>
but pylint does not contains filename in output
************* Module mymodule
E: 22: invalid syntax
...
I try to replace the char # with a newline \n:
sed -e "s/#/\n/g" > file.txt
this works fine.
Now there is problem with the char #, when is escaped with -:
eg.: 123#456-#789#777 should be:
123
456#789
777
The escaped char - itself can also be escaped:
eg.: 123#456-#789--012#777 should be:
123
456#789-012
777
How can i do this with ...
I want to filter out several lines before and after a matching line in a file.
This will remove the line that I don't want:
$ grep -v "line that i don't want"
And this will print the 2 lines before and after the line I don't want:
$ grep -C 2 "line that i don't want"
But when I combine them it does not filter out the 2 lines befor...
I have the following sed -e 's/<em\:update.*//g' install.rdf > install.rdf in a bash script, and it works on command line, but in the bash script install.rdf ends up a blank file.
When I run sed -e 's/<em\:update.*//g' install.rdf > install.rdf command line, then 2 lines are stripped out of the file.
Any idea why sed -e 's/<em\:update....
I want to get the lines from a file from the line which contains the last occurance of a given word.
Ex:
True, there have been some
changes in the plot. In the original,
Kane tried to buy high political
office for himself. In the new version,
he just puts politicians on his payroll.
If I give "In" then I need
offic...
So let's see how can we do this: trim the text width within a certain value, say, 10.
For lines longer than 10, break it into multiple lines.
Example:
A text file:
01234567
01234567890123456789abcd
0123
should be changed to:
01234567
0123456789
0123456789
abcd
0123
So how can we do it using sed or awk as short as possible?
...
i have some strings with this pattern in some files:
domain.com/page-10
domain.com/page-15
....
and i want to replace them with something like
domain.com/apple-10.html
domain.com/apple-15.html
i have found that i can use sed command to replace them at a time but because after the numbers should something be added i guess i have ...
So my dear SOers, Let me be direct to the point:
specification: filter a text file using pairs of patterns.
Example: if we have a file:
line 1 blabla
line 2 more blabla
line 3 **PAT1a** blabla
line 4 blabla
line 5 **PAT1b** blabla
line 6 blabla
line 7 **PAT2a** blabla
line 8 blabla
line 9 **PAT2b** blabla
line 10 **PAT3a** blabla
line 1...
suppose to have the following string:
commandone{alpha} commandtwo{beta} {gamma}commandthree commandtwo{delta}
and I want to abtain:
commandone{alpha} beta {gamma}commandthree delta
well I'm triying with regex and sed, I can easily find if is it present the pattern I look for
/commandtwo{.*}/ but not erasing commandtwo and the foll...
Say I have a file containing these lines:
tomatoes
bananas
tomatoes with apples
pears
pears with apples
How do I replace every line containing the word "apples" with just "oranges"? This is what I want to end up with:
tomatoes
bananas
oranges
pears
oranges
...
Hello friendly computing people,
This is a two part question. I'm writing two shell scripts with the goal of doing a 'find and replace' in all the index.php files in a folder and its subfolders.
The first shell script is this:
echo "running on all directories…"
find . -name '*.php' -exec ./search_replace.sh {} \;
which then runs th...
I have some problem with replace command.
Input file i have this
{a[$1]=a[$1]FS$2}END{for(i in a) print i,a[i]}
I want to replace with single quotes
'{a[$1]=a[$1]FS$2}END{for(i in a) print i,a[i]}'
Using the below mentioned command
find input.txt -exec sed 's/{a[$1]=a[$1]FS$2}END{for(i in a) print i,a[i]}/'{a[$1]=a[$1]FS$2}END{f...
How to replace the following pattern in a java project
catch(SQLException e) {
\\TO DO
}
with
catch(SQLException e) { S.O.P(); }
Please note that the file will have other patterns like
catch(IOException e) {
// To Do }
which should not be changed.
I tried
sed 's/catch\(SQLException[^\}]*}/catch(SQLException e)...