How to run spell check on multiple files and display any incorrect words in shell script?

You can install aspell with Homebrew on OS X. brew info aspell lists supported languages. brew install aspell –lang=en,fi,jp aspell check opens a file in an interactive spell checker: for f in *.txt; do aspell check $f; done aspell list prints all unrecognized words: cat *.txt | aspell list | sort -u Learned words are … Read more

Can you pass an environment variables into kubectl exec without bash -c?

/usr/bin/env exports values passed in key=value pairs into the environment of any program it’s used to invoke. kubectl -n nmspc exec “$POD” — env curIP=123 script01 Note that you should never use $runScript or any other unquoted expansion to invoke a shell command. See BashFAQ #50 — I’m trying to put a command in a … Read more

zip columns from separate files together in bash

NAME paste — merge corresponding or subsequent lines of files SYNOPSIS paste [-s] [-d list] file … DESCRIPTION The paste utility concatenates the corresponding lines of the given input files, replacing all but the last file’s newline characters with a single tab character, and writes the resulting lines to standard output.

Achieve Local Function

Bash does not support local functions, but depending on your specific script and architecture you can control the scope of your function name through subshells. By replacing the {..} with (..) in your definition, you’ll get the output you want. The new definition of usage will be limited to the function, but so will e.g. … Read more

Declaring global variable inside a function

declare inside a function doesn’t work as expected. I needed read-only global variables declared in a function. I tried this inside a function but it didn’t work: declare -r MY_VAR=1 But this didn’t work. Using the readonly command did: func() { readonly MY_VAR=1 } func echo $MY_VAR MY_VAR=2 This will print 1 and give the … Read more

tech