Using different delimiters in sed commands and range addresses

You can use an alternative regex delimiter as a search pattern by backslashing it: sed ‘\,some/path,d’ And just use it as is for the s command: sed ‘s,some/path,other/path,’ You probably want to protect other metacharacters, though; this is a good place to use Perl and quotemeta, or equivalents in other scripting languages. From man sed: … Read more

sed, replace first line

You can use sed with something like sed ‘1 s/^.*$/<?php/’ The 1 part only replaces the first line. Then, thanks to the s command, it replaces the whole line by <?php. To modify your files in-place, use the -i option of GNU sed.

sed command in dry run

Remove the -i and pipe it to less to paginate though the results. Alternatively, you can redirect the whole thing to one large file by removing the -i and appending > dryrun.out I should note that this script of yours will fail miserably with files that contain spaces in their name or other nefarious characters … Read more

Combining two sed commands

sed is a scripting language. You separate commands with semicolon or newline. Many sed dialects also allow you to pass each command as a separate -e option argument. sed -i ‘s/File//g;s/MINvac\.pdb//g’ /home/kanika/standard_minimizer_prosee/r I also added a backslash to properly quote the literal dot before pdb, but in this limited context that is probably unimportant. For … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)