Questions about bash only, as opposed to other Bourne/POSIX shells. For all Bourne/POSIX-style shells, use the /shell tag instead.

learn more… | top users | synonyms

1
vote
3answers
84 views

What are the proper tools to setup a remote compilation and running (something like ideone)?

I'm trying to achieve similar functionality in a server for community programming and I've drafted this to wrap up another take on oneide's functions: From a Perl CGI I build a script like this (not ...
0
votes
1answer
241 views

auto create groups directories on user logging in

Below is my real and effective UIDs and GIDs. My task is to implement a bash script (Ubuntu 10.10 desktop) which should auto create 3 directories rtkit, admin, pr007drdl (group names) in /home ...
6
votes
3answers
336 views

Undo bg; Undo putting a process into the background?

I've started a long running and machine hog process. I've hit CTRL-Z to stop it. I've then put it in the background with bg. Oops, I should have restarted with fg so that I could easily stop and start ...
4
votes
1answer
1k views

Remapping Ctrl-l in bash

Can one remap Ctrl-l in bash to execute more than just clear? I know normally it just clears the screen. I'm looking to change that to clear the screen and list my pwd like so: Ctrl-l:clear;ls;
0
votes
3answers
426 views

Prevent init daemon echoing on TTY

Below is an init script which starts/stops a daemon. The daemon is unfortunately printing the parsed packet data (from /home/nuthan/program/server), a socket server written in perl, listening to a ...
8
votes
3answers
8k views

Safe way to pass password for >1 programs in bash

I'm writing a bash script, and need to ask user for his password and pass it to openssl. Whilst openssl can read the password itself, I need for two runs of the program and don't want to ask the user ...
4
votes
1answer
1k views

Bash alias arguments [duplicate]

Possible Duplicate: How to pass parameters to an alias? I am trying to make a bash alias that will allow me to quickly make an archive of the current git repo. My current alias is: alias ...
3
votes
3answers
284 views

bash function to find a directory recursively

How can I write a bash-function that finds a specific parent directory. Here's my setup: /home/user/dev/project1/branch1/deeply/nested/module/structure The app-server used for devs is located at: ...
7
votes
2answers
3k views

What is bash's meta key?

I tried to use xmodmap to map META_L to the MENU key but it doesn't seem to be accepted by bash as the meta key. So, I am wondering how these components (keyboard, X, xterm, bash) relate to each in ...
2
votes
3answers
4k views

How to delete the oldest directory in a given directory? [duplicate]

Possible Duplicate: Shell script for moving oldest files? I have a backup directory that stores x other directories that require backuping. I need something that will run before another ...
5
votes
1answer
6k views

Bash: Merge foldername from variable with filename

First I write a configfile with all my parameters like this path="/home/test/" I name it test.conf. Then I write a shell script with this content, name it test, and make it executable with chmod ...
5
votes
4answers
6k views

Apt-get autocompletion

I am currently running 64-bit Debian Wheezy. I am having some trouble with auto completion for apt-get. I have bash-completion installed. If I am logged in as root in a shell, I can use auto ...
2
votes
3answers
6k views

Batch renaming files with pattern

I have some files named like these: 63018933.mp4?token=1325697436_b0c3e70c6e339380b4a484c576a8c287 63808488.mp4?token=1325697401_4ae5f7a68d93873c8881b303e7655e14 How do I rename all them to, for ...
10
votes
1answer
949 views

Why is my bash prompt getting bugged when I browse the history?

Often when I start looking at history of commands some of the characters from a command displayed aren't erased, for example: What's happening: prompt$ some_command prompt$ some_commanother_command ...
3
votes
1answer
989 views

Issue with WINCH signal - what am I overlooking?

I am having an issue with the WINCH signal in the following code which is from a tutorial located at developerWorks®: #!/bin/bash trap 'get_window_size' WINCH # trap when a user ...
6
votes
9answers
12k views

How do I write a test for system login?

I've written a Python CGI script that invokes bash commands, and it needs to test for a successful login on the host. How do I write a test for that? For example, could I create a bash script that ...
4
votes
4answers
7k views

How to totally fork a shell command that is using redirection

I've written quite a few shell scripts over the years (but I'm certainly not a sysadmin) and there's something that always caused me troubles: how can I fork a shell command immune to hangups in the ...
12
votes
3answers
5k views

Prompt for sudo password and programmatically elevate privilege in bash script?

I'm currently working on a bash script that installs and sets up various programs on a stock Linux system (currently, Ubuntu). Because it installs programs and copies a number of files to various ...
8
votes
2answers
4k views

How to remove last part of a path in bash? [duplicate]

Possible Duplicate: How to delete part of a path in an interactive shell? Is there a short-cut in bash that lets you delete the last part of a path? Example: /usr/local/bin should become ...
7
votes
6answers
1k views

Why is bash standard on Linux?

Most recent Linux distributions include bash as default shell, although there are other, (arguably) better shells available. I'm trying to understand if this is some historical leftover that nobody ...
8
votes
3answers
7k views

bash: Use a variable to store stderr|stdout redirection

Is there any way to redirect stdout and stderr via variable like adding command options in script? For example I have a script: #!/bin/bash -x TEST=">/dev/null 2>&1" OPT='-p -v' mkdir $OPT ...
4
votes
1answer
379 views

Custom bash completion with directories and a fixed set

I'm trying to setup a bash completion, and have two problems For parameter one, I needed a completion for directories For parameter two, a fixed array for completion, I just don't know how to let ...
6
votes
3answers
2k views

How can I find what is interfering with CTRL+F?

I'm running LinuxMint12 with Gnome with Cario-Dock and I have a logitech G15 keyboard. I set up a bash script with the extra keys to take the active window, resize it, and move it to a specific ...
3
votes
5answers
194 views

gnome-dictionary no-window option does not work

I would like to have a bash dictionary so I found gnome-dictionary. However, just typing gnome-dictionary will bring up a GUI box. In gnome-dictionary --help, and in the man file, it says a -n or ...
3
votes
3answers
579 views

Escaping argument in bash script?

I'm writing a bash script wherein I want to check that one of the arguments passed to it is a valid group. I have the line if [ `grep -c -e '\b$2\b' /etc/group` -eq 0 ]; then echo "Error: $2 is ...
7
votes
2answers
3k views

Screen status bar to display current directory for zsh/bash shell

I use GNU screen a lot with zsh as my shell. It would be a nice feature (I think) to be able to display the current directory name (not the full path) as the tab title. I can do that with CTRL+A ...
2
votes
1answer
487 views

Script that unpacks a initrd, allows editing of the preseed.cfg and the packs it to cpio and gzip again

I want to program a script that allows what is said in the title. So basically I gunzip the initrd, than unpack the cpio, open vi to allow editing, save, pack with cpio, and gzip again, so nothing ...
0
votes
1answer
572 views

Directory diff in bash script

I have a bash script that expands two archives (jar files) into two directories and then does a diff of the two folders. I want the diff to be piped into a file so I do this in the bash file. diff -r ...
5
votes
1answer
1k views

Autocomplete of filename in directory

This question is quite similar to this one, but I can't understand the solution. I also know this tutorial, but still I am unable to understand what I am doing wrong. I am trying to autocomplete the ...
3
votes
3answers
405 views

Automatic cleanup of Bash history

How can Bash history be automatically cleaned up? For example Remove detectable typos from history (ls-lh does not show up in which, so it is removed, I meant to type ls -lh) Clean excessive spaces ...
2
votes
2answers
136 views

Bash completion for `unset` command

How can I setup bash completion for the unset command, like when you use echo $XXX, you can get a completion for XXX?
1
vote
1answer
1k views

Capture user input while doing other things

Is there a way to have the output of a subprocess (something other than 'sleep' below) be dovetailed with the output from a foreground command-loop? For example: while true do echo "updating ...
2
votes
3answers
1k views

Ignore or catch division by zero

How do I ignore the division by zero error in Bash? Example 1: (Doesn't work) echo $((1/0)); echo "yay"; echo $((1/0)) || echo "yay"; Example 2: echo -n $(echo -n $((1/0))) 2> /dev/null; echo ...
1
vote
4answers
1k views

Checking for the existence of files against a list

I have a "command" text file that issues a data file download command on each line. I send the command file to bash. However, a small percentage of the downloads fail. Here is the algorithm I ...
4
votes
4answers
432 views

Show output on another “screen” and return to normal when done

I want a similar behavior as less vim nano etc. uses. Is this possible to achieve with bash?
6
votes
1answer
2k views

How do I get the difference between two timestamps?

I am creating a simple backup script. I would like to have a message saying "You last backed up x days ago" on login. I can create a file when I do the backup "backup/.last_backup_timestamp" but what ...
11
votes
4answers
2k views

Is it possible to configure ctrl-w (delete word)?

Normally, Ctrl-w deletes back to the last whitespace. Is it possible to configure it to use additional characters, such as /? Edit: To be more clear: I don't want to configure the key for it, I want ...
6
votes
1answer
992 views

Why bash time is more precise then GNU time?

The buitin bash command time gives milisecond precision of execution and GNU time (usually /usr/bin/time) gives centisecond precision. The times(2) syscall gives times in clocks, and 100 clocks = 1 ...
11
votes
4answers
1k views

How do I choose specific files in a different directory using bash?

I want to list (or delete, or do some other operation) on certain files in a directory, like this: $ ls /opt/somedir/ aa bb cc aa.txt bb.txt cc.txt $ ls /opt/somedir/(aa|bb|cc) ## pseudo-bash ...
3
votes
3answers
2k views

After installing oh-my-zsh: … /.zshrc:source:34: no such file or directory … /.oh-my-zsh/oh-my-zsh.sh

I just tried to install oh-my-zsh. I get the following error when I try to run rvm: zsh: command not found: rvm I also get the following error when I try to open a new tab: ...
5
votes
3answers
496 views

Is there a shortcut in bash to delete the last segment of a path?

I've become pretty proficient with a number of bash shortcut keys that make my bash-ing faster: C-a/C-e, C-u, C-w, M-f/M-b, C-r etc. One common task that I haven't found a good shortcut for though is ...
1
vote
3answers
429 views

Customize the way stderr is appended to a file

I have an issue with a shell script that uses rsync to synchronize 2 directories. I'm storing the result of the rsync command (whether it's successful or not) to a file named status and in case there ...
2
votes
1answer
742 views

Remap bash vi keys?

I use Dvorak and vi, so when I found out about the vi mode in Bash, I was very excited. However, it would be even better if I could remap the movement keys to be the ones that I use in vi (I swap keys ...
5
votes
1answer
2k views

In Bash, why is PROMPT_COMMAND set to something invisible?

On RHEL6 and CentOS 6, /etc/bashrc sets PROMPT_COMMAND here: case $TERM in xterm*) if [ -e /etc/sysconfig/bash-prompt-xterm ]; then PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm ...
2
votes
2answers
95 views

How to output only given chars?

How can I crop unneeded chars, and only output what I need? For example: input: ASDFQWER output: DFQ I mean in this case I need only the 3.-4.-5. chars of the string. How do I do that?
6
votes
2answers
438 views

How to do block selection in `screen`

In vim, there's a CtrlV to do block selection. How can I do it in screen?
6
votes
3answers
3k views

How to setup trap in bash functions?

I can setup trap in bash scripts but not bash functions. For example, source the code below and run f, now try Ctrl+C, it's not been trapped! How to setup trap in bash functions? 4 trap ctrl_c ...
5
votes
1answer
236 views

Why is the following command killing a system?

Anyone understand the following code , running in bash ? :(){ :|:& };: It seems to be a "fork" bomb on Linux.
1
vote
1answer
202 views

Tab and complete

Is the key binding for tab to complete in the readline settings set implicitly. Because when I outputted bind -q complete I got this in return complete can be invoked via "\C-i", "\e\e". ...
2
votes
0answers
295 views

What happens when you background a function which calls another function?

Question says it all on the tin. Can someone explain to me what goes on here ? I'm trying to find out how to background a process in a script that calls another function and reliably terminate it when ...