New answers tagged

3

If you mean that the replacement should not be done if there are more than 8 adjacent (TAB)s, you could do: sed ' s/_/_u/g; # escape _ s/|/_p/g; # escape | s/(TAB)/|/g; # use a single character in place of (TAB) s/.*/<&>/; # add leading and trailing non-| character s/\([^|]\)|\{2,8\}\([^|]\)/\1|\2/; # replace up to 8 | provided ...


4

I'm not sure I understand how the "maximum 8" clause is supposed to apply, but the naive approach would be something like this: sed 's/\((TAB)\)\{2,8\}/(TAB)/g'


4

& is special in the replacement text: it means “the whole part of the input that was matched by the pattern”, so what you're doing here replaces user=&uidX with user=user=&uidXsysuserid.. To insert an actual ampersand in the replacement text, use \&. Another thing that looks wrong is that . in the search pattern stands for any character (...


2

Here's one possible way sed '/)\. $/ { n /^PORT/ i\ 0 closed ports }' Testing $ sed '/)\. $/ { n /^PORT/ i\ 0 closed ports }' < input ... Nmap scan report for w.x.y.z (x.x.x.x) Host is up (0.00090s latency). 0 closed ports PORT STATE SERVICE 21/tcp open ftp ... Nmap scan report for w.x.y.z (x.x.x....


1

(Posting @glennjackman comment as a community answer to prevent system from autodeleting the question) jq '.body.test2 = ["hi"]' will do it


0

You can use N in sed to pull next line of input in the pattern space, and then work on two lines at once. As an example, conditionally pull the next line in when seeing a foo, and then do a replacement on both lines. (Note that consecutive lines with foo will break this.) echo -e "asf\nfoo\nbar" | sed -e '/foo/N;s/o\nb/od\nc/' Also, GNU sed has the -z ...


0

What you can try doing is the following: Obtain professional PHP editor with code formatting, for example PHPEclipse, PHP Storm or NuSphere, or even Notepad++, on Linux it's Kate and on MacOS it's TextMate You can search all files for given strings and remove them You can also format the code again (code formatter, including HTML), so that you can see ...


7

As someone who's had their PHP-based front end breached, code injected into it, and took a stab at trying to clean up the injected code themselves (after restoring the site from a clean tarball of the framework and modifications I made), allow me to give some real-world expertise and answers: the only real answer to fixing this is to start over. Trying to ...


0

Using XMLStarlet: #!/bin/sh xml ed -u "//ThreadGroup[. = contains(@testname, '$1')]/@enabled" -v "true" -u "//ThreadGroup[. = not(contains(@testname, '$1'))]/@enabled" -v "false" Assuming your XML is valid (I added a <SomeTag> root tag, and properly delimited the empty <ThreadGroup> node with />. I also set the enabled attributes to ...



Top 50 recent answers are included