Shell scripting notes – searching matching filenames and matching content

Some random shell scripting notes for future reference:

On OS X: find -E . -regex ‘pattern’

  • -E specifies extended regex support

On Linux flavors: find . -regextype posix-regex -regex ‘pattern’

Posix vs basic vs extended regex character class differences.

Pipe result to newfile > : eg grep ‘pattern’ file > output.txt

Pipe result appending to file > : eg grep ‘pattern’ file >> output.txt

Capture output as String? : $(some expression)

Iterate files:

for f in some-file-pattern or something producing a list of files
do ... done

Use find . -name ‘pattern’ to recurse matching files down subdirs

Find with a regex for multiple patterns:

find -E . -regex ".*ext1|.*ext2|.*ext3"

first line of file:

head -n 1 filename

grep -o : only display match

Match patterns in file and output matches or matched groups:

Match files, patterns in files, and pipe matches to file:

Weblogic Portal 10.3.6 from template: [Security:090820]The internal variable ServletInfoSpi is null and it should not be

On starting a new Weblogic Portal 10.3.6 domain created from a template of a previously created domain, you see this error:

Caused by: javax.servlet.ServletException: [Security:090820]The internal variable ServletInfoSpi is null and it should not be
at weblogic.security.providers.saml.SAMLServletAuthenticationFilter.init(SAMLServletAuthenticationFilter.java:51

As noted in this post here, the *.jks keystore files are omitted when creating from a template (is this a defect?). Copy them across from a new domain created via the config wizard into the root dir of your newly created domain fixes the issue:

[mwhome]\user_projects\domains\your_domain\*.jks