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
18
votes
2 answers

How can I get remaining args after pulling out parsed items using getopts?

I want to parse some arguments to a bash script using getopts but want to be able to access the remaining args that are not included in the option list. So for example, if I have a call: % script -a -b param -c param -d other arguments here I would…
Tim
  • 1,879
  • 3
  • 18
  • 16
18
votes
5 answers

Unzip from stdin to stdout - funzip, python

The goal is to read a zip file from stdin and uncompress to stdout. Funzip works and is the solution I am looking for, the zip contains a single file, unfortunately funzip fails when the compressed file size is around 1GB or greater: funzip error:…
chillvibes
  • 181
  • 1
  • 1
  • 4
18
votes
6 answers

Hide the output of a shell command only on success?

Hiding the output of a shell command usually involves redirecting stderr and stdout. Is there any builtin facility or command which by default hides the output but on error dumps all the accumulated output? I would like to run this as a wrapper for…
18
votes
2 answers

Is there a global .bash_profile for all users on a system?

So I stumbled across svn color and thought it was something useful all our devs would appreciate. The read me for this says to put some code in your ~/.bash_profile, but I'm wondering how I might include this globally on the server, so it's a…
Steve Robbins
  • 1,932
  • 5
  • 23
  • 26
18
votes
14 answers

Reasons for missing IP info in `last` output on pts logins?

I have five CentOS 6 linux systems at work, and encountered a rather strange issue that only seems to happen with my userid across all the linux systems I have... This is an example of the problem from entries I excepted from the last…
Mike Pennington
  • 8,305
  • 9
  • 44
  • 87
18
votes
4 answers

cp command prompts on overwrite even with -f

I am trying to copy all newer jpgs from one folder to another using the following command cp -u --force /home/oldfolder/*.jpg /home/newfolder/ and I get the following promt: cp: overwrite `/home/newfolder/4095-181.jpg'? The '-u' I know is working…
icelizard
  • 732
  • 3
  • 10
  • 20
18
votes
8 answers

How to get the fully qualified name (FQN) on Unix in a bash script?

I have tested hostname on several servers (RedHat, Ubuntu), and hostname -f has proven unreliable, returning sometime the short name only (as described in this question). I can see the fqn in the aliases: hostname -a (one of the aliases is the fqn I…
VonC
  • 2,683
  • 5
  • 30
  • 49
18
votes
7 answers

How to parse and convert ini file into bash array variables?

I'm trying to convert an ini file into bash array variables. The sample ini is as below: [foobar] session=foo path=/some/path [barfoo] session=bar path=/some/path so these…
Flint
  • 631
  • 5
  • 10
  • 18
18
votes
2 answers

What does "--" (double dash) mean in this shell command?

I have this shell command: kill `cat -- $PIDFILE` What the double -- does here? Why not use just kill `cat $PIDFILE`
daniels
  • 1,205
  • 5
  • 16
  • 26
17
votes
2 answers

~/.bashrc is NOT sourced on ssh 'command'

At the end of .bashrc I added: touch /tmp/bash_noninteractive_test Run: /usr/bin/ssh -v -C root@example.com 'ls' On the host (logged in interactively before): % ls -l /tmp/bash_noninteractive_test ls: cannot access /tmp/bash_noninteractive_test:…
LetMeSOThat4U
  • 1,371
  • 2
  • 17
  • 35
17
votes
2 answers

Fix for bash line-wrapping & backspace display bugs on Mac OS X?

When I open up Terminal (on Mac OS X 10.5.8) and type a long command line: ...the text doesn't go to the next line when it wraps around: Also, sometimes when I type a command and then backspace (or up-arrow or ^U): ...the entire line isn't…
Daryl Spitzer
  • 2,996
  • 9
  • 33
  • 40
17
votes
2 answers

How can I measure the cumulative network usage of a process, from execution beginning to end

I want to measure how much bandwidth git pull uses, preferably by prefixing git command with desired program, i.e. nettally git pull Alternatively, is there some sneaky way to accumulate nethogs / wireshark data and add up the figures after…
caduceus
  • 305
  • 2
  • 7
17
votes
1 answer

Change nice level of currently running script

I would like to change the nice level of the currently running script: #!/bin/bash nice_it ( ) { nice ps -o "%p %r %y %x %n %c %a" } nice_it That does not work, since nice tries to change the nice level of the command started by it. Is it…
blueFast
  • 4,200
  • 13
  • 37
  • 54
17
votes
5 answers

Check if directory exists using home character (~) in bash fails

Why does the following bash check if a directory fail? if [ ! -d "~/Desktop" ]; then echo "DOES NOT EXIST" exit 1; fi ~/Desktop does indeed exist. This is on a Mac by the way. The problem is with this type of script read -p "Provide the…
Justin
  • 5,328
  • 19
  • 64
  • 84
17
votes
4 answers

How to delete empty source directories when moving folders with rsync?

rsync can be coaxed into moving folders very similarly and superiorly to traditional mv with the following options: rsync -axvvES --remove-source-files source_directory /destination/ However one thing I cannot yet seem to get it to do is to remove…
ylluminate
  • 1,155
  • 2
  • 17
  • 35