Hi. I made a script that spawns a remote shell or runs a local shell whether it's on the current machine or not:
#!/bin/bash
# By: benoror <[email protected]>
#
# spawns a remote shell or runs a local shell whether it's on the current machine or not
# $1 = hostname
if [ "$(hostname)" == "$1" ]; then
bash
else
ssh "$1.local"
fi...
What's the easiest way to recursively list files in a given directory and its subdirectories, that are writable by the group which owns them? I'm using Debian 5.
...
Hi,
I need to generate the strings STA and STB.
STA and STB are strings of length 10, and each one can contain only the characters A,T,G or C.
I have to generate all possible combinations of STA, and depending on STA, I generate STB.
The ways is that the character A is always associated with T and viceversa and G with C and viceversa...
I'm trying to write a Bash script that will SSH into a machine and create a directory. The long-term goal is a bit more complicated, but for now I'm starting simple. However, as simple as it is, I can't quite seem to get it. Here's my code:
#!/bin/bash
ssh -T [email protected] <<EOI
# Fix "TERM environment variable undefined" ...
I'm trying to do something like
var=0
grep "foo" bar | while read line; do
var=1
done
Unfortunately this doesn't work since the pipe causes the while to run in a subshell. Is there a better way to do this? I don't need to use "read" if there's another solution.
I've looked at http://stackoverflow.com/questions/124167/bash-v...
Hi all,
This has happened to me a few times and I'd like to save time in the future when running into this situation.
I often either help colleagues out with site deployments or web server configuration. Most times I find myself spending more than what I'd like figuring out:
Which apache is running
Which httpd.conf is being used
Whic...
This is probably a very stupid question, but in Bash I want to do the following substitution:
I have in some files the line:
DATE: 12 jan 2009, weather 20C
and I want to change it to
DATE: XXXX
Using sed I guess I had to say "starting after "DATE:", please remove the rest and insert " XXXX".
Is this approach OK and how can...
Hi,
in a bash script I am implementing some functions, that take parameters
The problem is when the parameters instaed of being MONDAY is END OF THE WEEK
How can I pass this parameter to the function so the function
function week{
TIME=$1
}
takes a $TIME "END OF THE WEEK" and not just "END" ?
Thanks
...
Hi,
I have in a bash script:
for i in `seq 1 10`
do
read AA BB CC <<< $(cat file1 | grep DATA)
echo ${i}
echo ${CC}
SORT=${CC}${i}
echo ${SORT}
done
so "i" is a integer, and CC is a string like "TODAY"
I would like to get then in SORT, "TODAY1", etc
But I get "1ODAY", "2ODAY" and so
Where is the error?
Thanks
...
Hello,
I'm working on a shell script that does certain changes on a txt file only if it does exist, however this test loop doesn't work, I wonder why?
Thank you!
while [ ! -f /tmp/list.txt ] ;
do
sleep 2
done
...
I would like to make sure that an applescript can be converted to bash. Are there any ideas on how to do this? And if so, I'll place a simple applescript below to give you an example of how the script runs. In more clarity, I simply want a bash script or shell script to do what my applescript is doing. I want it to "enable" or change the...
I am writing a bash script that is supposed to do some confirmation and also install software. First step of the installation process is that I am being asked to confirm the EULA and type 'yes'. Is there a way to get the 'yes' in there from the bash script?
...
I have a shell script that I want to ask the user if they want to continue. If they type 'n' and press enter the script will exit.
If they press 'y' and enter it will continue to run. I have this at the top of my script but it continues regardless of what I type.
What am I doing wrong ?
goon=
while [ -z $goon ]
do
echo -n 'Do yo...
I want to implement a progress bar showing elapsed seconds in bash. For this, i need to erase the last line shown on the screen ( command "clear" erases all the screen, i need to erase only the line of the progress bar and replace it with the new informations ).
Final result should look like :
"Elapsed time 5 seconds"
...
If you have a list in python, and you want the elements from 2 to n can do something nice like
list[2:]
I'd like to something similar with argv in Bash. I want to pass all the elements from $2 to argc to a command. I currently have
command $2 $3 $4 $5 $6 $7 $8 $9
but this is less than elegant. Would would be the "proper" way
...
Hi!
I'm attempting to convert dates from one format to another:
From e.g. "October 29, 2005" to 2005-10-29.
I have a list of 625 dates. I use Awk.
The conversion works -- most of the time.
Hovewer, sometimes the conversion won't happen at all,
and the variable supposed to hold the (converted) date remains
undefined.
This always happen...
When I use putty to log on to a bash shell, I want it like real term emulator in Linux. That means:
If I set shell to vi editing mode, the cursor would be a vertical line in inserting mode, and a block in a command mode.
How can I do this?
Thanks all you folks!
...
How would I do something like:
ceiling(N/500)
N representing a number.
But in a linux bash script
...
How would I round the result from two divided numbers, e.g.
3/2
As when I do
testOne=$((3/2))
$testOne contains "1" when it should have rounded up to "2" as the answer from 3/2=1.5
...
I'm trying to do some variable expansion in bash but somehow the result is truncated/rotated. Here's a sample my code:
x="no-cabac,level=3,ref=3,bframes=0,subme=0,weightp=0"
tts="{$x}"
echo $tts
This prints: }no-cabac,level=3,ref=3,bframes=0,subme=0,weightp=0
I expected: {no-cabac,level=3,ref=3,bframes=0,subme=0,weightp=0}
If I chan...