New answers tagged

0

First create a sed script from those two files: paste -d$'\t' find.csv replace.csv | sed -e 's:/:\\/:g; s:\t:/:; s:^:s/:; s:$:/g;:' > myscript.sed That will replace all occurrences of strings in find.csv with the strings in replace.csv. It will fail if any of the lines in find.csv contain a tab character, as that is being used by paste as the ...


1

Use the following code for replacing the "dots" :%s/\./_/g <ENTER> Here "_" is replaced word.


2

try using other chars rather than / for separation maybe? sudo sed -i "s@listen = 127.0.0.1:9000@listen = '/var/run/php56-fpm.sock'@g" /etc/php-fpm.d/www.conf OR sudo sed -i "s/listen = 127.0.0.1:9000/listen = '\/var\/run\/php56-fpm.sock'/g" /etc/php-fpm.d/www.conf The problem is that you are not escaping the / as \/ but using @ as separator will fix ...


3

First of all, A single quote may not occur between single quotes, even when preceded by a backslash., ref Bash Manual Second, you may want to use some other char as separator instead of / as you have / in the replacement string. So as a result: sudo sed "s#listen = 127.0.0.1:9000#listen = '/var/run/php56-fpm.sock'#g" /etc/php-fpm.d/www.conf don't ...


3

The way you've written the script, the changes are made to the main C++ source file; thus the first time it runs, you replace 30.0 with 30, and the second time it runs, the first sed won't find anything to replace... The following should work (also fixing the quoting issue): #!/bin/bash Rpl_array="30 60 90 120 150 180 210 240 270 300 330 360 390 420 450 ...


1

You want to modify the file iron_ablation_phi_nonzero_checking.cpp in each iteration of the loop, but your sed commands replace the initial values of some variables by new values. That works only for the first iteration; when you enter the second iteration of the loop, the file contains already the result of the first replacement, rather than the initial ...


0

Firstly, I agree with the comments above: Don't use sed to recover from being hacked. You will always wonder if you missed something. Restore from backup, period. However, the literal question you asked, how to remove a long string everywhere it appears without escaping every special character, is somewhat easier to handle. I'm making some ...


1

you can use sed -i "s+< /script>+< /script-->+g". So final command would become find . -type f -name "*.php" -exec sed -i "s+< /script>+< /script-->+g" {} +


0

you can use the following command to save the lines, excluding empty lines and lines starting with # in a new file cat <file to be read> | egrep -v '^#|^$' > <file to be written at>


2

[expanded from my comment to the OP]. Create on the repo a directory flat which holds a copy of all the files, but in one flat list. The copies would be hard links, so take no space. Do the same on the local machine. You can then rsync from the local flat directory to the remote flat directory. This will update all the remote files as rsync preserves remote ...


0

You definitely can use rsync with a changing directory structure and there are some interesting options you might not be aware of, in particular -H which preserves hard links. I'll describe my own scenario. This may or may not work for you, but I hope you at least find it interesting. SCENARIO: You have a large directory with lots of files in a directory ...


0

I think that's a job for Unison ! I haven't played with it for years, but I think it could do exactly what you're asking for... The home page says: Unison is a file-synchronization tool for OSX, Unix, and Windows. It allows two replicas of a collection of files and directories to be stored on different hosts (or different disks on the same host), ...


2

I think rsync is the wrong tool, as are find and mv. My recommendation is instead to make use of a software configuration management system. These include Subversion, Git, Mercurial, Bazaar among others. All of which can easily handle changes of tree structure. In the structure you describe, you have tree structure A on your client system and a repository ...


2

Reading between the lines, I assume you want to make your disassembly more readable by removing addresses on lines that are not referred to by jump and similar instructions. This awk assumes the number in the last but one column is an address when the last column begins "<". It reads the disassembly once, remembering all such addresses in an array, then ...


2

A Perl solution: $ perl -lne '$k{"$_:"}++ for split(/\b/); push @l,$_; }{ map{s/\S+:/$k{$&}<2 ? " " x length($&) : $&/e; print}@l;' file 0f a2 cpuid a9 01 00 00 00 test eax,0x1 74 01 je a <myFunc+0xa> c3 ret a: 0f 0b ...


2

Here's a starting point for you: #!/bin/bash PHONEFILE=/path/to/your/file # Prompt for search and replace numbers # and simply exit if either is empty # (in your actual script, you'll need to flesh this out with # proper validation of phone number formats, error messages etc.!) read -p "Number to search for: " oldnum if [ ! "$oldnum" ]; then exit; fi ...



Top 50 recent answers are included