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
32
votes
4 answers

Writing to stdin of background process

I'm on an Ubuntu 10.04 box, and started a server in the background (myserver &) over ssh. It's been running fine, but I need a way to get at the server's stdin, as the only way to control the server is through this method. Is there some way to get…
tajmorton
  • 435
  • 1
  • 4
  • 6
32
votes
3 answers

How set PATH for all users in Debian?

I have a Debian Lenny server, and I would like the www-data user to have /usr/local/zend/bin in its PATH, so it can execute a script in cron as www-data. How do I add /usr/local/zend/bin to PATH, so www-data can execuate files in /usr/local/zend/bin…
Sandra
  • 10,303
  • 38
  • 112
  • 165
31
votes
3 answers

How to zip files with a size limit?

I have a script that zip files from a folder. I want to make sure that the zipped file is not more than 10 MB. If the size is more than 10MB, it should create another ZIP file. Is there any command (or other method )that can be used for this?
Vishnu
  • 711
  • 2
  • 8
  • 15
31
votes
3 answers

Did a cat /dev/urandom - Broken terminal

Out of curiosity, when your shell character set breaks from doing something like cat /dev/urandom is there a way to fix that in place?
31
votes
7 answers

Don't need the whole line, just the match from regular expression

I simply need to get the match from a regular expression: $ cat myfile.txt | SOMETHING_HERE "/(\w).+/" The output has to be only what was matched, inside the parenthesis. Don't think I can use grep because it matches the whole line. Please let me…
Alex L
  • 591
  • 2
  • 5
  • 12
31
votes
5 answers

Remove IP with ip command in linux

If I add two IPs like this: ip addr add 1.1.1.1/24 dev eth2 ip addr add 1.1.1.2/24 dev eth2 and then I try to delete one of like this: ip addr del 1.1.1.2/24 dev eth2 BOTH IPs will be deleted and I don't know how to handle it. Any one knows how to…
Hamed JML
  • 443
  • 2
  • 5
  • 10
30
votes
19 answers

Shell Command for Getting IP Address?

Is there a bash command to find the IP address for an Ubuntu box? I need to find the IP address so I can ssh into the machine later.
opierce
  • 413
  • 1
  • 4
  • 5
29
votes
2 answers

Bash script count down 5 minutes display on single line

I would like to have a count down of 5 minutes, updating every second and showing the result on the same line. Is this even possible with Bash scripting?
ptheofan
  • 411
  • 1
  • 4
  • 6
29
votes
6 answers

How to use a custom .bashrc file on SSH login

I've found that with the new company I'm working with I often have to access linux servers with relatively short lifetimes. On each of these servers I have an account, but whenever a new one is created, I have to go through the hassle of…
gsgx
  • 392
  • 1
  • 3
  • 6
29
votes
12 answers

How can I display the IP address of an interface?

If I want to display the IP address that is assigned to eth1, how can I do this in Bash?
user47556
  • 509
  • 1
  • 5
  • 11
28
votes
4 answers

How to delete all hidden files and directories using Bash?

The obvious solution produces an exit code of 1: bash$ rm -rf .* rm: cannot remove directory `.' rm: cannot remove directory `..' bash$ echo $? 1 One possible solution will skip the "." and ".." directories but will only delete files whose…
Yonatan Broza
  • 475
  • 2
  • 6
  • 11
28
votes
4 answers

sed replace all tabs and spaces with a single space

I got a string like the following: test.de. 1547 IN SOA ns1.test.de. dnsmaster.test.de. 2012090701 900 1000 6000 600 now I want to replace all the tabs/spaces inbetween the records with just a single space so I can easily use…
Zulakis
  • 4,153
  • 14
  • 48
  • 76
28
votes
5 answers

Pass a pipe to a command that expects a filename

Say I have a command foo which takes a filename argument: foo myfile.txt. Annoyingly, foo doesn't read from standard input. Instead of an actual file, I'd like to pass it the result of another command (in reality, pv, which will cat the file and…
Steve Bennett
  • 5,750
  • 12
  • 47
  • 59
28
votes
4 answers

Run a bash script after EC2 instance boots

I have a script on an EC2 instance that remotely starts another instance. Once this instance has fully loaded (finished booting) I want it to automatically run a bash script, what would be the best way to do this? I need everything to be fully…
SSH This
  • 495
  • 1
  • 5
  • 8
28
votes
10 answers

How do I find out whether a port is available on Ubuntu 8.04?

Is there any command I can run from bash that will tell me whether a port is already open?
Codebeef
  • 1,449
  • 4
  • 19
  • 20