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
41
votes
6 answers

prevent xargs from quitting on error

According to the man page, xargs will quit if one of the execution lines exits with an error of 255: If any invocation of the command exits with a status of 255, xargs will stop immediately without reading any further input. An error message is…
JDS
  • 2,598
  • 4
  • 30
  • 49
40
votes
6 answers

What command prints a string as "big ascii text art" in bash?

I'm looking for a program that turns an ASCII string into something like the "ascii art" below: .-"^`\ /`^"-. .' ___\ /___ `. / /.---. …
raoulsson
  • 4,763
  • 10
  • 34
  • 29
40
votes
2 answers

Why does redirecting 'script' to /dev/null/ allow 'screen' to work while su'ed as another user?

I was su'ed into a user to run a particular long running script. I wanted to use screen but I got the error message "Cannot open your terminal '/dev/pts/4' - please check." So I Googled around and came across a forum post that instructed to run $…
Ichorus
  • 485
  • 1
  • 6
  • 12
40
votes
2 answers

How do ulimit -n and /proc/sys/fs/file-max differ?

I notice that on a new CentOS image that I just booted up off of EC2 that the ulimit default is 1024 open files, but /proc/sys/fs/file-max is set at 761,408 and I'm wondering how these two limits work together. I'm guessing that ulimit -n is a…
bantic
  • 1,519
  • 3
  • 14
  • 17
39
votes
5 answers

Using sed to remove both an opening and closing square bracket around a string

I'm running this command in a bash shell on Ubuntu 12.04.1 LTS. I'm attempting to remove both the [ and ] characters in one fell swoop, i.e. without having to pipe to sed a second time. I know square brackets have special meaning in a regex so I'm…
Xhantar
  • 1,042
  • 1
  • 8
  • 11
39
votes
4 answers

BASH Scripting, su to www-data for single command

I am working on automating the creation of subversion repositories and associated websites as described in this blog post I wrote. I am running into issues right around the part where I su to the www-data user to run the following command: svnadmin…
Brendon Dugan
  • 503
  • 1
  • 4
  • 6
39
votes
10 answers

How do I read multiple lines from STDIN into a variable?

I've been googling this question to no avail. I'm automating a build process here at work, and all I'm trying to do is get version numbers and a tiny description of the build which may be multi-line. The system this runs on is OSX 10.6.8. I've seen…
Robert K
  • 572
  • 1
  • 5
  • 12
39
votes
6 answers

How do I pipe a downloaded file to standard output in bash?

How is it possible to pipe out wget's downloaded file? If not what alternatives should I use?
Alex
  • 2,357
  • 5
  • 32
  • 41
38
votes
3 answers

#!/bin/sh vs #!/bin/bash for maximum portability

I usually work with Ubuntu LTS servers which from what I understand symlink /bin/sh to /bin/dash. A lot of other distros though symlink /bin/sh to /bin/bash. From that I understand that if a script uses #!/bin/sh on top it may not run the same way…
cherouvim
  • 794
  • 3
  • 21
  • 37
38
votes
6 answers

bash script: repeat command if it returns an error

I would like to create a loop that repeats a ncftp transfer if it returns an error. I'm a little unsure how the exit code variable can be used in a loop. Would something like this work? until [$? == 0]; do ncftpput -DD -z -u user -p password…
Roy
  • 4,376
  • 4
  • 36
  • 53
38
votes
3 answers

How do you escape characters in heredoc?

I'm working with a bash script trying to stop it from attempting to replace variables inside my heredoc. How do set a heredoc to either A) escape the variable names instead of parsing them or B) return the entire string untouched? cat >…
Xeoncross
  • 4,449
  • 12
  • 43
  • 56
38
votes
7 answers

If I launch a background process and then log out, will it continue to run?

Asking this after a prolonged discussion with a coworker, I'd really like a clarification here. I launch a background process, either by appending "&" to the command line or by stopping it with CTRL-Z and resuming it in background with "bg". Then I…
Massimo
  • 70,200
  • 57
  • 200
  • 323
37
votes
7 answers

How can I determine what is taking up so much space?

I was using df -h to print out human readable disk usage. I would like to figure out what is taking up so much space. For instance, is there a way to pipe this command so that it prints out files that are larger than 1GB in size? Other ideas? Thanks
syn4k
  • 569
  • 1
  • 6
  • 12
37
votes
3 answers

Copy a file's owner permissions to group permissions

How can I copy a file's user/owner permissions to it's group permissions? For example if the permissions are 755 I want them to become 775. Clarification: 755 -> 775 123 -> 113 abc -> aac Bonus if I can do this recursively for all files in a…
AnnanFay
  • 610
  • 2
  • 7
  • 13
37
votes
8 answers

SSH into a box with a frequently changed IP

I have some cloud boxes that change their IP frequently. I ssh using the hostname but have to edit the known_hosts file every time the server launches because of this error message: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ …
coneybeare
  • 621
  • 1
  • 7
  • 14