Tag Info

New answers tagged

1

find . -type f | xargs sed -i 's/abc/xyz/g' Use -maxdepth option if you don't want the action to take place recursively in your current working directory.


0

You are not using regular expressions correctly. tes* means te with any number of ss following it, so test-file-1 will be renamed to file 1t-file-1: $ rename -n 's/tes*/file 1/' * test-file-1 renamed as file 1t-file-1 Similarly, ^* will match the empty string appearing at the start, so in effect it's like ^, but with a an inifinite loop: $ rename -n ...


3

Try: $ sed -e 's/\[\[\("[[:alpha:]]\)/[\1/g' ARD.json ["A ["b [["8 ["c ["F [["1 With GNU sed: sed -re 's/\[\[("[[:alpha:]])/[\1/g'


0

To clarify the point above: Once it looks OK, you can run this command to remove the backup files: $ find dest/ -name "start dot ~" -delete This didn't seem to work for me, whereas: $ find dest/ -name "start dot star ~" -delete did. Not sure if that's a typo or something not set up right my end!


0

You have not said what you want done with the lines that don't contain a valid IP so I assume you just want to ignore them. Then, all you need to do is make sure the entire line matches three groups of one to three numbers ([0-9]{1,3}), then a final group of one to three numbers. Here are three ways of doing that: GNU sed sed -r ...


1

If you use a modern sed, the following works: sed -e 's/\(^\|[^0-9]\)1\.2\.3\.4\($\|[^0-9]\)/\1NEWIP\2/' I.e., replace 1.2.3.4 by NEWIP, if at the beginning of the line or preceded by a non-digit, and if additionally at the end of the line or followed by a non-digit. With an old sed version that doesn't support extended regexps, it's more complicated. ...


3

You're using the wrong tool. wc will count lines of input but since you're using sed -i, there are no lines printed so nothing for wc to count. Even without it, the sed command would have printed all lines of the file so it still would not have worked correctly. Here's a different approach: Use perl instead find . -name \*.php \ -exec perl -i -lpe ...


0

sed is very peculiar about read - it will only do it for the line which matched its pattern - and it will always do it last. sed won't read out a file for a matching pattern if the pattern ceases to match before it flushes the line. At least that's how I think it works - I'm pretty good with sed but r still baffles me sometimes. Anyway, the trick is to let ...



Top 50 recent answers are included