Hi
I'm a shell script beginner. I use Bash, and have written a simple procedure to check if a named sub-directory exists in a list of directories. I use pushd to change to each directory in turn, and then popd to return to the start directory.
Each 'pushd' and 'popd' writes output (the new directory) to the command-line, which is messy. Is there any way to suppress the output of pushd and popd in particular, and arbitrary commands in general?
Here's the script so far:
project_dirs="$HOME/Projects $HOME/projects"
setproj()
{
shopt -q
for search_dir in $project_dirs; do
pushd $search_dir
if [ -d $1 ]; then
echo "found project $1";
fi
popd
done
}
setproj $1
This produces output like:
~ > bash bashmacro cdr-analyser
~/Projects ~
~/projects ~/Projects ~
found project cdr-analyser
~ >
Thanks!
--Ant
I'm a shell script beginner. I use Bash, and have written a simple procedure to check if a named sub-directory exists in a list of directories. I use pushd to change to each directory in turn, and then popd to return to the start directory.
Each 'pushd' and 'popd' writes output (the new directory) to the command-line, which is messy. Is there any way to suppress the output of pushd and popd in particular, and arbitrary commands in general?
Here's the script so far:
project_dirs="$HOME/Projects $HOME/projects"
setproj()
{
shopt -q
for search_dir in $project_dirs; do
pushd $search_dir
if [ -d $1 ]; then
echo "found project $1";
fi
popd
done
}
setproj $1
This produces output like:
~ > bash bashmacro cdr-analyser
~/Projects ~
~/projects ~/Projects ~
found project cdr-analyser
~ >
Thanks!
--Ant