Questions tagged [bash]

Bash is the Bourne Again SHell, the successor to the classic Unix sh (shell).

bash is the Bourne Again SHell, the successor to the classic Unix Bourne shell (sh). It's the default shell on many Linux distributions, including RedHat, CentOS, Debian, and Ubuntu.

The premier online guide is the BashGuide.

3527 questions
2
votes
4 answers

GNU Screen and .bashrc

I am trying to launch GNU Screen using my .bashrc. I'm almost there: if [ -z "$STY" ]; then exec screen -dR else exec gnome-terminal fi This is wrong though! The first case works, screen launches when I open a terminal. But the second part…
devin
  • 1,246
  • 3
  • 20
  • 27
2
votes
5 answers

Many concurrent SSH commands in a bash script?

My Bash-Foo is not strong. Right now I have something like function update_project { for i in server-{1,2,3,4} ; do echo "Updating $i" ssh $i "git pull" done } The number of servers is growing every day, and since each update takes…
linkedlinked
  • 446
  • 1
  • 3
  • 11
2
votes
2 answers

How do I clear history of the bash logs? Also, do not log any of my users' bash logs?

How do I do that? I want to clear everything as well as not log anything from now on.
Alex
  • 8,471
  • 26
  • 75
  • 99
2
votes
2 answers

How to run linux bash script from web browser?

Hi I have web server on it also. I had made simple bash script using vi editor..which will open file and then add some lines into it at last it will save automatically...and after that 2-3 linux command will be run as a specific user. Now I want to…
sahil007
2
votes
3 answers

What's wrong with this bash prompt?

I use the following entry in ~/.bashrc file to colorize the prompt and display current branch of git repository: PS1='\[\e[1;32m\]\[\u@\h\]\[\e[m\] \[\w\]\[\e[1;1m\]\[$(__git_ps1 " (%s)")\] \[\e[1;1m\]\[$\] \[\e[m\]' This works almost fine, except…
takeshin
  • 1,471
  • 3
  • 21
  • 28
2
votes
4 answers

Ubuntu - Bash - How to Ctrl + R

I can't seem to locate recent commands I've run when I do Ctrl + R in my terminal, nor can I see them when I hit the up arrow. It was a long command. Is there a length limit to what is stored? I may have used sudo. Is sudo history stored…
Greg_the_Ant
  • 489
  • 7
  • 26
2
votes
2 answers

Bash edit file and keep last 500 lines

I am looking to create a cron job that opens a directory loops through all the logs i have created and deletes all lines but keep the last 500 for example. I was thinking of something along the lines of tail -n 500 filename > filename Would this…
icelizard
  • 732
  • 3
  • 10
  • 20
2
votes
3 answers

Run FTP session from bash script

I'm trying to write a BASH script to test if an FTP site that I own is running. I therefore want the bash script to connect to the FTP site, log in with a dummy account and redirect the output to a file that I can then grep to confirm that the…
Adam Salkin
  • 181
  • 1
  • 4
  • 8
2
votes
1 answer

Run script when POST data is sent to Apache

Among my several years of running servers there seems to be a pattern with most spam activity. My question/idea is that is there a way to tell Apache to run a script when POST data is detected? What I would want to do is perform a reverse DNS lookup…
Natalie Adams
  • 745
  • 1
  • 6
  • 16
2
votes
2 answers

Explanation of the init.d/scripts Fedora

Below is a copy of vsftpd, i need some explanations of some of the scripts mentioned below in this script: #!/bin/bash # ### BEGIN INIT INFO # Provides: vsftpd # Required-Start: $local_fs $network $named $remote_fs $syslog # Required-Stop: $local_fs…
Sparky
  • 242
  • 1
  • 5
  • 12
2
votes
2 answers

difference between braces and normal brackets in bash?

what is the difference between braces and normal brackets in bash? FYI... I did not get it in the related questions list and also not able to locate it in questions search. Please point me to the question if it has been already asked.
BHS
  • 121
  • 1
  • 5
2
votes
4 answers

How do I reference the value of a constructed environment variable in a loop?

What I'm trying to do is loop over environment variables. I have a number of installs that change and each install has 3 IPs to push files to and run scripts on, and I want to automate this as much as possible (so that I only have to modify a file…
2
votes
1 answer

Is there a & (BASH) equivalent for DOS Batch files?

I'm thinking not since that violates the principle of batching. So what are my options if I want to launch two apps in windows in one script.
Peter Turner
  • 2,178
  • 9
  • 33
  • 45
2
votes
2 answers

Redirecting program errors to both log and error file

I've a Java standalone program scheduled to run as cron at every 10 minutes I want to catch/write errors thrown by this Java program both in the log file and also as a separate error file (MyJavaStandalone.err). I know the following commands: Errors…
Gnanam
  • 1,459
  • 13
  • 26
  • 32
2
votes
2 answers

Bash script to create mass series of directories

I need to create a Bash script to go into every user's home folder, seek out a wp-content folder, create a directory uploads under it, and then chmod 0756 uploads. How do I achieve this? I imagine I need to use find with a regexp/regex, and then…
ServerChecker
  • 1,518
  • 2
  • 14
  • 35