How can you suppress the 'Terminated' message that comes up after you kill a process in a bash script?
I tried set +bm, but that doesn't work.
I know another solution involves calling 'exec 2> /dev/null', but is that reliable? How do I reset it back so that I can continue to see stderr?
Thanks
...
Bash is getting a little long-in-the-tooth. Windows has PowerShell (formerly known as Monad), which is capable of dealing with richer objects than just lines of text. Is there any equivalent new powerful shell for Linux/Mac?
It should be of similar expressiveness and functionality to Bash, but not afraid to tackle things in a differ...
Currently I'm doing some unit tests which are executed from bash. Unit tests are initialized, executed and cleaned up in a bash script. This script usualy contains an init(), execute() and cleanup() functions. But they are not mandatory. I'd like to test if they are or are not defined.
I did this previously by greping and seding the sou...
I'm looking for the best way to take a simple input:
echo -n "Enter a string here: "
read -e STRING
and clean it up by removing non-alphanumeric characters, lower(case), and replacing spaces with underscores.
Does order matter? Is tr the best / only way to go about this?
...
I have a shell script that executes a number of commands, and if any of the commands exit with a non-zero exit code the shell script should exit.
...
How to match a single quote in sed if the expression is enclosed in single quotes:
sed -e '...'
For example need to match this text:
'foo'
...
How do I check if a directory contains files?
Something similar to this:
if [ -e /some/dir/* ]; then echo "huzzah"; fi;
but which works if the directory contains one or several files (the above one only works with exactly 0 or 1 files).
...
I have a bash shell script in which I would like to pause execution until the user presses a key. In DOS, this is easily accomplished with the "pause" command. Is there a linux equivalent I can use in my script?
...
I know I once know how to do this but... how do you run a script (bash is OK) on login in unix?
...
When I use "[\e[34m]sometext" i get sometext in blue, but can I specify the shade of blue somewhere?
...
I'm trying to write a script to allow me to log in to a console servers 48 ports so that I can quickly determine what devices are connected to each serial line.
Essentially I want to be able to have a script that, given a list of hosts/ports, telnets to the first device in the list and leaves me in interactive mode so that I can log in ...
I'm trying to use cygwin as a build environment under Windows. I have some dependencies on 3rd party packages, for example, GTK+.
Normally when I build under Linux, in my Makefile I can add a call to pkg-config as an argument to gcc, so it comes out like so:
gcc example.c `pkg-config --libs --cflags gtk+-2.0`
This works fine under...
eg.
me$ FOO="BAR * BAR"
me$ echo $FOO
BAR file1 file2 file3 file4 BAR
and using the "\" escape character:
me$ FOO="BAR \* BAR"
me$ echo $FOO
BAR \* BAR
I'm obviously doing something stupid.
How do I get the output "BAR * BAR" ?
...
In bash, environmental variables will tab-expand correctly when placed after an echo command, for example:
echo $HOME
But after cd or cat, bash places a \ before the $ sign, like so:
cd \$HOME
If I use a variable as the second argument to a command, it won't expand at all:
cp somefile $HOM
What mysterious option do I have in my ...
What are some elements in your favorite bash prompt?
I like to have an indicator of the success of the most recent command, like so (in .bashrc):
function exitstatus {
EXITSTATUS="$?"
BOLD="\[\033[1m\]"
RED="\[\033[1;31m\]"
GREEN="\[\e[32;1m\]"
BLUE="\[\e[34;1m\]"
OFF="\[\033[m\]"
PROMPT="[\u@\h ${BLUE}...
Is it possible to share the same bash history file instance amongst all the terminal windows in real time? I want commands executed in one window to be available to all other terminal windows without having to restart them.
...
I'd like to run a long rsync command in Cygwin by double clicking on a .sh file in Windows. It must start in the file's containing directory (e.g. /cygdrive/c/scripts/) so that relative paths work. Anyone gotten this to work?
Note: I've just found chere, a Cygwin package that manages Windows context menus (Bash Prompt Here). It might...
I am using bash in os X Terminal app, and my custom $PS1 breaks when I scroll through my history.
PS1="${BLUE}\u${CYAN}@${RED}\h${BLUE}\w\n\[${red}\$${NC}\]"
also tried
PS1="${BLUE}\u${CYAN}@${RED}\h${BLUE}\w\r\n[${red}\$${NC}]"
The problem seems to be in the newline. I have used this bash prompt on Slackware no prob.
...
I am working on a bash script where I need to conditionally execute some things if a particular file exists. This is happening multiple times, so I abstracted the following function:
function conditional-do {
if [ -f $1 ]
then
echo "Doing stuff"
$2
else
echo "File doesn't exist!"
end
}
Now, whe...
I am writing a bash script to deal with some installations in an automated way... I have the possibility of getting one such program in 32 or 64 bit binary... is it possible to detect the machine architecture from bash so I can select the correct binary?
This will be for Ubuntu machines.
...