Simple replace with sed command

Here's an example to scan/replace recursively:

grep -lr -e ' ' * | xargs sed -i 's/ //g'

Another sample:

echo "/tmp/testme.txt" | xargs sed -i 's/XXX/YYY/g'

Another sample, the dash i parameter makes it replace inline

sed -i 's|/bin/zip|/usr/bin/zip|g' testme.txt

Using sed with an input file:

sed -f sed.txt input.txt

input.txt

1 two three 1
four 5 six

sed.txt

s/1/one/g
s/5/five/

With the following sed commands

  • delete lines with [Control]
  • replace ? with a space
  • delete any lines that contain ONLY white space
  • delete any trailing white space
  • replace Word dash with a simple -
  • replace > < with ><
  • G tells sed to double space the output file

sed.txt

/\[Control\]/d
s/?/ /g
/^\s*$/d
s/:space:*$//
s/–/-/g
s/> </></g
G

Awk statments to find line lengths

Use this to get a file of bad records:

awk 'length < 517' SBN_GIFT_MANIFEST_20130209_234013.TXT > BAD-RECORDS-SBN_GIFT_MANIFEST_20130209_234013.txt

This gives you a quick count:
awk 'length < 517' SBN_GIFT_MANIFEST_20130209_234013.TXT | wc -l

Delete File on Reboot

SysInternals has a utility to delete files upon reboot just in case the files are locked. See the notes below:

There are several applications, such as service packs and hotfixes, that must replace a file that's in use and is unable to. Windows therefore provides the MoveFileEx API to rename or delete a file and allows the caller to specify that they want the operation to take place the next time the system boots, before the files are referenced. Session Manager performs this task by reading the registered rename and delete commands from the HKLM\System\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations value.

This applet dumps the contents of the pending rename/delete value and also reports an error when the source file is not accessible. Here is example output that shows a temporary installation file is schedule for deletion at the next reboot:

C:\>pendmovesPendMove v1.02
Copyright (C) 2004 Mark Russinovich
Sysinternals - wwww.sysinternals.com

Source: C:\Config.Msi\3ec7bbbf.rbf
Target: DELETE

The included MoveFile utililty allows you to schedule move and delete commands for the next reboot:

usage: movefile [source] [dest]Specifying an empty
destination ("") deletes the source at boot.

An example that deletes test.exe is:

movefile test.exe ""

Running XAMPP on Different Ports

You will need to access the application by the following:
http://localhost:8080/
https://localhost:444/

Change port 80 to 8080 twice in the following file:
F:\Programs\xampplite\apache\conf\httpd.conf

Change port 443 to 444 three times in the following file
F:\Programs\xampplite\apache\conf\extra\httpd-ssl.conf