The source command reads and executes commands from the file specified as its argument in the current shell environment. Source is a shell built-in in Bash and other popular shells used in Linux and UNIX operating systems.
This may seem silly, but does /dev/null have a return value?
I'm looking at this code:
if diff file1 file2 > /dev/null;
then echo "same files!" `
else .....
Except isn't diff evaluated false if its output is directed to /dev/null?
Updated 2021-04-06: when using the relative pathname to invoke a script, I noticed the most general format wasn’t working properly! I’ve updated the echo $BASH_SOURCE in that form to echo . instead.
How do I know the script file name in a Bash script?
How can I determine the name of the Bash script file inside the script itself?
Like if my script is in file runme.sh, then how would I make it to display "You are running runme.sh" message without
What platform independent way to find directory of shell executable in shell script?
According to POSIX:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sh.html
there are some cases where it not obvious. For example:
If the file is not in the current working directory,...
How can I set the current working directory to the directory of the script in Bash?
I'm writing a Bash script. I need the current working directory to always be the directory that the script is located in.
The default behavior is that the current working directory in the script is...
I am trying to understand a test script, which includes the following segment:
SCRIPT_PATH=${0%/*}
if [ "$0" != "$SCRIPT_PATH" ] && [ "$SCRIPT_PATH" != "" ]; then
cd $SCRIPT_PATH
fi
...
And: "Why does this particular script have this outcome?"
From Getting the source directory of a Bash script from within, based on some code snippets offered by user l0b0 in his comment on that
How can I get the source directory of a Bash script from within the script itself?
How do I get the path of the directory in which a Bash script is located, inside that script?
I want to use a Bash script as a launcher for another application. I want to change the working directo...
I want to make a number of arrays (successively) available to a function in a script. The data I want to exploit in array form is dynamic and I need to somehow import from a text file with data int...
Can I call a function of a shell script from another shell script?
I have 2 shell scripts.
The second shell script contains following functions
second.sh
func1
func2
The first.sh will call the second shell script with some parameters and
will call func1 and f...
How to check if a string contains a substring in Bash
I have a string in Bash:
string="My string"
How can I test if it contains another string?
if [ $string ?? 'foo' ]; then
echo "It's there!"
fi
Where ?? is my unknown operator...
How can I run arbitrary bash scripts on files via Webpack without maintaining loaders for each file type?
It seems like Webpack runs tools that transform code via "loaders", rather than using the APIs of those tools directly. This adds a layer of abstraction over those tools which sometimes means the A...
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable of transforming, bundling, or packaging just about any resource or asset.
A framework for shell scripts that provides functions that can be used to load, include or call module shell scripts. It supports most shells based on bourne shell including Bash, Zsh and Ksh. A compiler can also be used.