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

4
votes
1answer
70 views

List the bash completion that's current active on a program?

Is there anyway to list the bash completion function in use for current command ? e.g for ls
2
votes
3answers
489 views

control number of started programs in bash

As part of my research project I'm processing huge amount of data splitted up into many files. All files in folder foo have to be processed by the script myScript involving all elements of folder ...
8
votes
3answers
2k views

My `which` command may be wrong (sometimes)?

I've compiled the last emacs version from the source code (v24.2) because the version installed on my machine is (quite) old for me (v21.3). I've done the usual: $configure --prefix=$HOME make make ...
3
votes
2answers
485 views

Are there any utilities to quickly add, list and remove command aliases?

I'd like to be able to quickly, on-the-fly add (and list/remove) command aliases so that they persist between shell restarts (as if they were added to .bashrc). Are there any ready ...
3
votes
2answers
658 views

How to enable local ~ autocompletion for scp?

Too late: The machine, OS and configuration in question is no longer in use, so I can't verify any more suggestions. I have not encountered this problem in Fedora or Arch Linux. If you are having this ...
0
votes
1answer
247 views

Pass output of a command as arguments to another(non-blocking)?

I was wondering how I can iterate over each line of the output of a command and pass it as command line arguments to another one. I want to do this in a non-blocking fashion as the output never ...
5
votes
3answers
2k views

How to set bash to run *.exe with mono?

Without any DE or even X, I want to use ./my.exe to run mono my.exe, like it works with python scripts.
4
votes
1answer
258 views

How does this git alias work?

Usually, git aliases are confined to a single command: git config --global alias.ci commit So, instead of git commit you could do git ci But it seems you can insert a function in there as well: ...
3
votes
3answers
744 views

Fastest way to open all files in a directory with multiple file extensions on commandline

If I want to open all mp4 files in a directory, I can simply do something like totem *.mp4. But how can I open all mp4 and all flv files in that directory with one command. I.e. I want to do something ...
2
votes
1answer
152 views

What does TAB do (no other things typed)

Just push TAB, the terminal gives me this: Display all 2637 possibilities? (y or n) What indeed does the TAB do for me?
3
votes
2answers
5k views

Merge two command results to one line when redirecting stdout

In a cron script I want to log CPU temperatures in the format [datetime] temp using date and acpi -t. How can I redirect (>>) these two commands to a single line in the log file?
2
votes
2answers
1k views

Escaping characters when passing arguments to a command

I regularly record audio files using my Android phone to WAV files to the internal storage of my phone. I'd like to write a Bash script to pull the most recent recorded file from my phone and move it ...
5
votes
2answers
5k views

Passing arguments with quotes and doublequotes to bash script

At this moment I have: #!/bin/bash screen -p 'ScreenName' -x eval 'stuff '"'"$@"'"'\015' echo eval 'stuff '"'"$@"'"'\015' But when I call my script as: # script.sh asd "asd" 'asd' my arguments ...
-1
votes
1answer
6k views

Bash function to compare two binary files [closed]

I need a function to compare 2 binary files, here the requirements: 2 files, not 3 or 4 files can't be assumed to exist avoid running checksum (CRC/MD5/SHA/...) until one must if running multiple ...
1
vote
3answers
3k views

How to rename files using sed?

This is an sed expression that was created by a contributor here. More specifically by @craig-sanders. $FileToMove is set to "2012-09-01 Home insurance quote_zz20.pdf" # use sed to extract folder ...
0
votes
3answers
83 views

how to access homedir by root user

I want to access root user's home directory /root/. However following commands dont lead me to the root directory. sudo -s cd ~ It leads to the home dir of regular user. How to access /root ...
3
votes
1answer
3k views

How to move file based on file name expression using shell script?

I want to achieve the following using a shell script. When a script is called with a file as a parameter, it should move the file based on a portion of its name. For example, "Car insurance ...
1
vote
2answers
799 views

Why “reverse-i-search” does not work on my centos sytem?

When i press CTRL+r, the "reaverse-i-search" works well: but then when i press "arrow up" key, none history commands show, just nothing happens! Any configuration not compare?
2
votes
2answers
1k views

How to pass a variable to an sh child process? [duplicate]

Possible Duplicate: How to “send” variable to sub-shell? I have a bash script and inside that script I do sh. How to pass a variable to the new shell? This is how it is ...
7
votes
5answers
5k views

Check if script is started by cron, rather than invoked manually

Is there any variable that cron set when it's running a program ? If the script is running by cron, I'll skip some parts; otherwise invoke those parts. How can I know if the bash script is started by ...
1
vote
2answers
3k views

How to create a md5-file for every folder in a drive recursivley?

I'm searching for a script which creates a md5 chechsum file for every single folder inside drive recursivley? I do have a copy of md5deep on my machine but I'm not that good in scripting bash.
17
votes
3answers
12k views

Piping from grep to awk not working

I am trying to grep the ongoing tail of file log and get the nth word from a line. Example file: $ cat > test.txt <<EOL Beam goes blah John goes hey Beam goes what? John goes forget it Beam ...
1
vote
5answers
8k views

bash execute read command from file

After some manipulations, I got the file with commands that I would be glad to be able to execute. Input file (name of file is inp2.txt): "02 - Beautiful Emptiness.mp3" "02 - Come. mp3" "02 - Go ...
1
vote
3answers
2k views

how to sum output of awk or other expression with xargs

Suppose i have the following bash shell script: #!/bin/bash export count=0; for i in `ls ./mydoc` ;do pdfinfo ./mydoc/$i | egrep Pages |awk {'print $2'} |xargs -+ $count ; ...
5
votes
4answers
4k views

Pgrep returns mutiple PIDs

My script accepts a process name as an input and kills it, I tried using pgrep but its returning two PIDs , one for the process which is running and one for the script which accepts the process name ...
4
votes
4answers
3k views

How do you colorize only some keywords for a bash script?

I am running some unit test code. The unit test code outputs regular text. There is a lot of the text so I want to highlight for the user important keywords. In this case the keywords are "PASS" and ...
15
votes
4answers
22k views

How can I use bash's if test and find commands together?

I have a directory with crash logs, and I'd like to use a conditional statement in a bash script based on a find command. The log files are stored in this format: /var/log/crashes/app-2012-08-28.log ...
14
votes
2answers
471 views

Can I make `rm` interactive only when using globbing? (in either bash or zsh or both)

Whenever I rm multiple items at once with shell globbing and there's even the slightest possibility that the pattern expands to more than I expect it to, I always try to remember to add -i, but (of ...
0
votes
1answer
229 views

The “cp p2 &2 &” command makes Konsole to disappear, is it a bug?

The goal is start a background process that copies the data from the pipe p2 to the STDOUT as p2 is feed with data by some other process. I guess the command is incorrect. Nevertheless, the Konsole ...
8
votes
5answers
2k views

Read and confirm shell script before piping from curl to sh (curl -s [url] | sh)

Whenever I have to execute a shell script from the web curl -s [url] | sh, I first open url in my web browser to make sure the script isn't malicious and is safe to run. I remember seeing a command ...
2
votes
0answers
451 views

How to use history commands with readonly PROMPT_COMMAND?

I'm sometimes logged in on a host which I do not control and where PROMPT_COMMAND is readonly. Is there some way to work around this to run history commands anyway, for example using PS1? I've tried ...
1
vote
3answers
2k views

Bash wait for jobs and limit job count [duplicate]

Possible Duplicate: Four tasks in parallel… how do I do that? Suppose a loop invoking a command grep -v '#' < files.m3u | sed 's/\\\\/\/\//g' | sed 's/\\/\//g' | while read line ...
7
votes
2answers
6k views

Why Bash unable to find command even if $PATH is specified properly?

I am specifying path to my command in the file /etc/profile: export PATH=$PATH:/usr/app/cpn/bin My command is located in: $ which ydisplay /usr/app/cpn/bin/ydisplay So, when I performing "echo ...
0
votes
1answer
726 views

add directory to shell profile [duplicate]

Possible Duplicate: How can I make a program executable from everywhere So, I'm new to Linux/Unix and am working in a corporate version of Red Hat at my company. Obviously I don't have full ...
3
votes
2answers
2k views

Scripting htdigest -c /path/to/file/$user $user $password in Bash

I want to be able to script with a password in variable $password. htdigest -c /etc/apache2/pw/$user $user $password At the moment it asks me to manually enter a password, this is not going to be ...
3
votes
1answer
961 views

What are the scope restrictions for setting shopt extglob. and other options?

My non-interactive bash shell has extglob off. I would like to turn it on in the statement immediately before a command, but I have noticed that when shopt -s extglob is within an if .. then .. else ...
24
votes
1answer
1k views

Why does echo >file use more real time than echo | sed >file?

The example, below, surprised me. It seems to be counter intuitive... aside from the fact that there is a whisker more user time for the echo | sed combo. Why is echo using so much sys time when it ...
1
vote
1answer
254 views

Making multiple calls to a program via a bash shell script

Suppose that I have a program make_ndx that outputs via the -o switch. I would like to call myprogram from a bash shell script and output two files, out1.ndx and out2.ndx. (myprogram takes a string ...
3
votes
1answer
2k views

Redirect stdout and stderr, with timestamps on stderr only

I'm trying to hack in better logging for a test program that I didn't write. I want all lines of STDERR output to have timestamps, but if possible I want to leave STDOUT alone. I also want one file ...
1
vote
1answer
2k views

Do shells support recursion?

I'm trying to write recursive functions in my shell scripts. Consider the following code: function printA { if [[ "$1" = 0 ]]; then return else echo "a$(printA $(("$1" - 1)))" ...
3
votes
2answers
214 views

place the aliased version of an existing command in /usr/bin/

I use Vim a lot, and I know how I can start vim in insert mode. So I have an alias named vii in my .bash_aliases file. On other hand I use Git a lot too, and I have this line in my .gitconfig: ...
22
votes
4answers
50k views

Shell script fails: Syntax error: “(” unexpected

I've been working on a script that automates setting up a development environment for Raspberry Pi development (step by step details that work are here). The script is linked in that article but ...
4
votes
2answers
1k views

Why can't I navigate into my Documents directory?

I'm in bash and running F17 as su. My pwd is /home/user and when I ls I see Desktop Documents Downloads Music Pictures Public Templates Videos However, I'm unable to cd into any of these. My ...
1
vote
2answers
5k views

Why the differences in color between SSH terminal sessions in OSX?

I'm trying to get the colors in an SSH terminal session with a CentOS machine to look the same as it does when I'm SSH'd into my Ubuntu server. If I run echo $TERM in both I get xterm-color as ...
5
votes
1answer
141 views

ask for comfirmation when file is replaced using a redirection

I'm a careless terminal driver scared of accidentally deleting files, hence using some aliases like alias rm='rm -i' for rm, mv, cp. How can I get a similar confirmation behavior for file redirections ...
2
votes
2answers
278 views

List all users and last time they read mail, pipeing to multiple output

I have one system that I would like to do a little clean up, so I would like to get all user accounts and last date they accessed they mail. It is a Debian system. So far I got to this: cut -d: -f1 ...
13
votes
4answers
12k views

what is the difference between ~/.profile and ~/.bash_profile

I want to know the difference between ~/.profile and ~/.bash_profile.
26
votes
1answer
175k views

How do I remove a directory and all its contents?

In bash all I know is that rmdir directoryname will remove the directory but only if it's empty. Is there a way to force remove subdirectories?
4
votes
3answers
18k views

How to copy between two remote hosts using tar piped into SSH from remote server when behind a firewall?

I'd like to transfer a directory between two servers, but compress the directory on the remote host before transfer, and then uncompress to another host. I'm sure it's possible to pipe everything all ...
2
votes
1answer
568 views

Backspace Acting like Enter in Bash

Whenever I type a mistake into my SCO machine, using bash, I press backspace and it is like pressing enter, but doesn't execute the command. e.g. bash-3.1$ ifcomfig "(backspace)" bask-3.1$ But if ...