Perl One-Liner for Replacing Multiple Lines of a Text file With Multiple Lines of Text

When executing ‘search-and-replace’ commands on ASCII under Linux, Unix (or *nix) operating systems, sed works or most cases and makes for reasonably straightforward reading of the script.

If  you want to replace multiple lines of text with multiple lines of text, following is a perl one-liner that does the trick and is much easier to wrangle than trying to do it in sed.

perl -i -pe "BEGIN{undef $/;} s:${EXISTING_LINES}:${REPLACEMENT_TEXT}:smg" file.txt
Continue reading “Perl One-Liner for Replacing Multiple Lines of a Text file With Multiple Lines of Text”

Adding the Contents of a Source File to the Beginning of a Target File

Following is *nix a command that you can use to add the contents of a source text file to the start of another text file (the source file).

echo -e '0r <source_file_name\nw' | ed -s <target_file_name
Continue reading “Adding the Contents of a Source File to the Beginning of a Target File”

Creating a Samba Share and Configuring an Access Control List for a Shared Directory Under Linux

Often administrators would like to configure a Samba share that enables users to have the same access to any files within the share.  Without some additional configuration, directories and files created by one user will not have the r/w permissions for other users that have access to that same share.

The end goal is to have a Samba share in which any new files are created with r/w permissions for a specific group to which all of the members of → Continue reading “Creating a Samba Share and Configuring an Access Control List for a Shared Directory Under Linux”

Updating all of the pom.xml Version Numbers in a Multi-Module Maven Project

To update the versions of all of the poms in a multiple module project use the versions-maven plugin.

To update

mvn versions:set -DnewVersion=1.4.0-SNAPSHOT

Will modify all of the versions of each of the poms to the version specified.  It will create a pom.xml.versionsBackup for each pom file that it modified.  You can then examine each to make sure that it is as you intended.

If you want, you can revert your change with

mvn versions:revert

If you are satisfied with → Continue reading “Updating all of the pom.xml Version Numbers in a Multi-Module Maven Project”