|
What is the difference between executing a bash script like A and sourcing a bash script like B?
A >./myscript B >source myscript
Started by Scottie T on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Sourcing is essentially the same as typing each....
Executions are independent from the parents environment.
So if you have configs or function definitions you should source and not execute .
Sourcing you get all the extra variables defined in the script .
|
|
I have 1 bash script that runs another bash script, however the first bashscript isn't waiting for the second one to complete before proceeding, how can I force it to wait?
For example:
#!/bin/bash # first.sh #call to secondary script sh second.sh echo...
Started by BassKozz on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Try using bash.
Make sure ?) Check the exit code of second.sh after you run it ( sh second.sh ; echo $? ) .
Flag ( bash -x first.sh ) to see exactly what commands your script is executing.
|
|
What have you found to be useful in your .bash_profile ?
What tips do you have for people editing theirs ?
SEE ALSO: Useful BASH aliases ( ie: alias ... )
EDIT: I've removed my original .bash_profile added my current solution as an answer
Started by _ande_turner_ on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at superuser):
This helps prevent="-iMFXrj4a"
I'm now importing my .bashrc....
Very useful
alias q='cd ..; ls'
I don't have a ~/.bash_profile_COMMAND and a function so the color changes if you do sudo bash or su -m root .
\[^[[0m\] \$ \" fi \`"
And then this.
|
Ask your Facebook Friends
|
I'm running autoconf and configure sets SHELL to '/bin/sh'. This creates huge problems. How to force SHELL to be '/bin/bash' for autoconf?
I'm trying to get this running on osx, it's working on linux. Linux is using SHELL=/bin/bash. osx defaults to /bin...
Started by Flinkman on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Please don't hose your system by doing it!)
Where is SHELL being set to that? What is being run with /bin/sh when you want /bin/bash?
configure scripts are meant to run anywhere....
Ln -f /bin/bash /bin/sh
:-P (No, it's not a serious answer.
|
|
I have a Cygwin bash script that I need to watch and terminate under certain conditions - specifically, after a certain file has been created. I'm having difficulty figuring out how exactly to terminate the script with the same level of completeness that...
Started by Barry Kelly on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at stackoverflow):
Here's my version:
#!/bin/bash function usage { echo "usage ;; esac shift done
The only real downside is....
This script looks like it'll do the job:
#!/bin/bash # Author: Sunil Alankar ## # recursive kill it, and with a couple more options.
|
|
What are some good bash tutorials? I would like to learn more about the bash shells commands and how to use them.
Started by Dynamic I on
, 4 posts
by 4 people.
Answer Snippets (Read the full thread at superuser):
Recommended online resources for learning bash scripting How to learn your way through Linux’s shell General search....
(Also available as a PDF file if you prefer that) .
Advanced Bash Scripting Guide from The Linux Documentation Project pages.
|
|
Hi
i have a .bash_favourites file which containes a list of my favourite commands.
I would like this be searchable via the normal bash history. ???
thanks
Ian
Started by stackian on
, 3 posts
by 3 people.
Answer Snippets (Read the full thread at stackoverflow):
If you want to replace the regular history with your favorites: Do chmod u-w... .
Cat ~/.bash_favourites >> ~/.bash_history history -r
If you want to make this permanent, you can probably just add these lines to ~/.bash_profile.
|
|
How do I get the path of the directory in which a bash script is located FROM that bash script.
For instance, lets say I want to use a bash script as a launcher for another application. I want to change working directory to the one where the bash script...
Started by Jim Robert on
, 19 posts
by 19 people.
Answer Snippets (Read the full thread at stackoverflow):
`pwd`
(remember the backtics) will get you the current directory from within your bash script% sure I'm following you (it's late....
And not where you run the script from:
#!/bin/bash $orpath = 'set original path'; $path = `pwd`; if [ $path.
|
|
Just witting a simple shell script and little confused:
Here is my script:
% for f in $FILES; do echo "Processing $f file.."; done
The Command:
ls -la | grep bash
produces:
% ls -a | grep bash .bash_from_cshrc .bash_history .bash_profile .bashrc
When
...
Started by sixtyfootersdude on
, 5 posts
by 5 people.
Answer Snippets (Read the full thread at stackoverflow):
Not a b
FILES="*bash*" doesn't work because the * wildcard won't be matched by a * wildcard,....
FILES="bash*" doesn't work because the hidden files name begin with a .
FILES=".bash*" works because the hidden files name begin with a .
|
|
I want to check whether a directory has files or not in bash. My code is here.
for d in {,/usr/local}/etc/bash_completion.d ~/.bash/completion.d do
[ -d "$d" ] && [ -n "${d}/*" ] &&
for f in $d/*; do [ -f "$f" ] && echo "$f" && . "$f" done done
The problem...
Answer Snippets (Read the full thread at stackoverflow):
$f; done.
If you set the nullglob bash option, through
shopt -s nullglob
then globbing will drop patterns/local}/etc/bash_completion.d ~/.bash/completion.d -maxdepth 1 -type f); do echo $f; .
|