Bash is a free shell for Unix-like operating systems from the GNU Project.

learn more… | top users | synonyms

5
votes
3answers
1k views

I want to execute the commands in a loop at the same time, not one after another

I'd like to write a loop ('for') that will do some action 'X' number of times. But instead of performing the actions sequentially, one after another, I'd like them to execute simultaneously (in ...
4
votes
1answer
422 views

Vim process stops after executing an external command

I've been using vim recently to program in C. I have created shortcuts for compiling and running the programs from within vim itself, but recently vim's process has been stopping after executing the ...
4
votes
3answers
216 views

Determine whether a bash script was launched by icon click or from terminal

I have a script that I want to have a different behaviour depending on whether it was launched from the terminal or by (double) clicking the icon in the file manager. Can I do this?
4
votes
3answers
20k views

Connect to WiFi network using Mac Terminal

Every time I try to find out how to do this, I find out how to do it on a linux, and it doesn't transfer. How do I connect to a WiFi network using Mac Terminal Bash?
4
votes
4answers
5k views

Using SQLite3 with Cygwin

I'm trying to use sqlite3.exe command shell with a mintty terminal in cygwin. I tried the program from a windows command prompt and it works. When I try to use it from the cygwin mintty terminal it ...
3
votes
1answer
313 views

Remote SSH Commands - bash bind warning: line editing not enabled

I am using bash 4.3.11(1) and have the following history plugin installed (via .bash_it): # enter a few characters and press UpArrow/DownArrow # to search backwards/forwards through the history bind ...
3
votes
3answers
237 views

Which files are run when I log into or reboot my machine?

I'm trying to figure out which "script" (really it's probably an "*rc" file) is running a particular command when I reboot my ubuntu machine. I've tried grepping for what is being displayed when I log ...
3
votes
1answer
1k views

Ping server/domain and capture its IP on Linux

With Windows, you could ping a given domain name and capture the IP as a variable, even if no reply was received. I believe the command looked something like this: ping domain.com for /f "tokens=1,2 ...
3
votes
1answer
1k views

Open Sublime Text 2 with new tab instead of new window

I've got an alias to open files in Sublime Text 2: alias sub='/Applications/Sublime\ Text\ 2.app/Contents/MacOS/Sublime\ Text\ 2' But this spins up another instance of Sublime Text 2 (complete with ...
3
votes
2answers
1k views

How to delete readonly variable in bash?

$ mySite="superuser" $ readonly mySite $ unset mySite bash: unset: mySite: cannot unset: readonly variable How can we delete mySite, as it is a readonly variable?
3
votes
2answers
3k views

Redirect stdout to a file when process is run in background

How can I redirect the stdout of a program to a file when it's run in the background? I have a program that generates output every second. When I run it normally and redirect to a file, the output ...
3
votes
2answers
2k views

Is there a face recognition command line tool?

I've download a lot of images in one directory including People and Landscape. I want to split the directory into two. I'm looking for a Linux command line tool to filter by face.
3
votes
1answer
980 views

~/.bashrc not sourced in a new lxterminal window

I added some lines to my ~/.bashrc like export JAVA_HOME=/opt/jdk1.6.0_22 I sourced it: $ source ~/.bashrc $ env | grep 'JAVA' JAVA_HOME=/opt/jdk1.6.0_22 Then I created a basic bash script under ...
3
votes
1answer
2k views

How can I extract only some specific folders from a tar.gz archive?

Let's say I have the archive website.tar.gz, inside is the following folder structure : home -mike -www -coolwebsite file1 file2 file3 etc. When I ...
3
votes
1answer
140 views

Attach command to execute when long-running thread returns

Let's say I've just started a command that will take a long time to execute, like hg clone the entire Pypy development set. Halfway through, I decide I'd like to run another process, like hg up, once ...
3
votes
1answer
848 views

How to write a script to sudo the last command [duplicate]

Usually, for some commands such as apt-get install xxx, I forget to add sudo first, then I need to retype it. What I want is in such cases, I just type a simple command, for example resudo. It will ...
3
votes
1answer
315 views

Force a bash script to run to completion where some items may stick

I've a Uni assignment I'm building that I need to run multiple times with multiple different parameters to check run times. At the moment I've a simple bash script that looks a little like the below - ...
3
votes
1answer
641 views

Can I make ssh-agent wait until I use ssh to prompt for a password?

I have ssh-agent set up to automatically start and prompt when I open a terminal window, as is explained here. It gets somewhat annoying though since many times when I open a shell I don't plan on ...
3
votes
4answers
323 views

Change directory upwards to specified goal

I'm often deep inside a directory tree, moving upwards and downwards to perform various tasks. Is there anything more efficient than going 'cd ../../../..'? I was thinking something along the lines ...
2
votes
2answers
152 views

What does “<>” exactly mean in “echo <> temp.txt”?

Non existing file $ ls file_not_exists.txt ls: cannot access file_not_exists.txt: No such file or directory $ echo <> file_not_exists.txt $ ls file_not_exists.txt file_not_exists.txt $ cat ...
2
votes
1answer
153 views

What this command :(){ :|: & };: does? [duplicate]

What does this shell command do in Linux :(){ :|: & };: How can it be used in Denial of Service attacks?
2
votes
2answers
165 views

Unable to get profile variable using ssh

Unable to retrieve the profile variable using ssh. server2 ==> user apptst ==> bash profile has $APPHOME variable. Was trying to retrieve the value from server1 using ssh but failed. Used options ...
2
votes
2answers
2k views

Find difference with mtime - and +

Can someone explain the difference with mtime - and + switch as both are not bringing back the results I need. I'm looking to delete all files older then 5 days find /mnt/sdb1/tmp/ -type f -mtime +5 ...
2
votes
3answers
1k views

Running rdesktop through a SSH tunnel in one command

I am running ssh server -L 3392:192.168.1.138:3389 in one terminal window, then running rdesktop 127.0.0.1:3392 in another to connect to a Windows machine through an SSH tunnel. How can I merge this ...
2
votes
1answer
8k views

Howto switch / chage user id witin a bash script to execute commands in the same script?

Is there a way to switch user identity within a script (executed as root as part of an installation process) to execute some commands without calling an external script, then return to root to run ...
2
votes
2answers
630 views

Disable Bash's programmable autocompletion (based on command)

Bash in my Fedora 16 seems to autocomplete arguments based on the command itself. So if I for example type cd Tab … it will only show directories. There are however far too many commands where ...
2
votes
4answers
675 views

Background job in bash is shutting down when the firing window is closed: how to avoid this?

You can go quickly to the question starting reading from 'Having said that' The following are details on my specific needs I'm on lubuntu oneiric and trying to create a desktop launcher to start / ...
2
votes
5answers
5k views

Move all files in sub-directories to current directory?

I've got files in a bunch of subdirectories, and I'd like to flatten them out and move them all to the current directory. I found this question, but adapting the answer to: mv * . didn't work. I ...
2
votes
1answer
531 views

How can I remap Ctrl+C to send an interrupt signal with another key?

I've got a process in bash that I can call to stop using Ctrl+C. As far as I can see, this equals to sending an exit(1) signal. I would like to loop through these processes for a list of different ...
2
votes
2answers
1k views

curl not uploading file to ftp

I am using curl to upload a file to ftp server. The same script is working on another system, but on this one after connecting to ftp it is not doing anything and connection times out. The detailed ...
2
votes
2answers
886 views

Remove bash startup behaviour (mac user)

When I start the terminal (which uses bash) a echoed message appears several times right before the message "You have mail." and it is added by someone that has used my computer. It also happens when ...
1
vote
1answer
524 views

How to prevent terminating command to send EOF to named pipes?

The problem I faced is exactly this one: http://www.linuxmisc.com/4-linux/d7863c256bccbfb6.htm I want to be able to run a program which takes stdin, and write data to it whenever I feel like ...
1
vote
1answer
167 views

Tmux causeing issues with Bash up-arrow

When using tmux, I have issues of ghost characters when using the Up and Down arrow keys in Bash. If I press UpArrow a few times and then press DownArrow a few times, then the first few characters of ...
1
vote
2answers
3k views

Spaces in Linux environmental variables?

Given directory: /media/foo/can haz/bar, I have tried editing bash.rc with: export Foo=/media/foo/can haz/bar export Foo=/media/foo/can\ haz/bar export Foo='/media/foo/can haz/bar' export ...
1
vote
1answer
1k views

Pass arguments to osascript via shell function in OS X Mountain Lion

The answer in How to open a new Firefox window with URL argument is broken in Mac OSX Mountain Lion (10.8.2). I can't comment on that answer or question, so I had to create a new question. It fails ...
1
vote
2answers
2k views

Diff and ignore lines missing in one file

I want to diff two files and ignore lines that are present in one file but missing in the other. For example File1: foo bar baz bat File2: foo ball bat I'm currently running the following diff ...
1
vote
4answers
2k views

less emulate a TTY to preserve piped color output

When you pipe something through less, the program usually discards color codes because it's not outputting to a TTY. So you have to add --color=always to the options for it to work. ls -l ...
1
vote
0answers
68 views

select files from a set [closed]

I need the Bash code for select file in a set of files. I use something like this find . -type f -name \*.txt to locate the set of files I want to work with. After that I would want select only the ...
0
votes
2answers
125 views

sum numbers in different lines in shell

i have 8000 lines similar to this <Flow flowId="1" timeFirstTxPacket="+0.0ns" timeFirstRxPacket="+924100.0ns" timeLastTxPacket="+199984927558.0ns" timeLastRxPacket="+199675473275.0ns" ...
0
votes
2answers
696 views

How to organize files in accordingly named directories from command line under Linux

I have a directory filled with various files, differently named (i.e. not named with a specific pattern) and with different extensions, and I want to put each file in a newly created subdirectory ...
0
votes
3answers
664 views

How do I remotely execute scripts on multiple servers, mix output

Hi I'm looking for a piece of software or some sort of technique that would enable me to do following in one terminal window: Take as input a list of ssh-enabled machines with login, password and ...
0
votes
1answer
87 views

alias: extract options from command

Apologies for the bad title. I couldn't come up with a better one. I want to alias a command to another command, and extract options from the text of the command itself. I realize this is unclear, ...
0
votes
1answer
3k views

Sending commands to an existing screen session?

I have a Java app running in a screen session (A game server), and I'd like to be able to write a script to send commands to it periodically (with cron probably), but I'm not sure how to send commands ...
0
votes
1answer
157 views

Pause all but x CPU-intensive tasks

I've got about 50 folders of data to process, and I've got a ruby script that processes a folder's files (which folder it processes is based on a .yml configuration file). And a computer with four ...
18
votes
5answers
150k views

How can I resolve the error “cannot execute binary file”?

When I login using SSH, all I can see is this... -bash: /usr/bin/id: cannot execute binary file -bash: [: : integer expression expected I couldn't do anything in here. Commands such as halt, ...
13
votes
4answers
9k views

Ubuntu grep, find etc: “Permission denied” and “No such file or directory” output

When I grep or find something I always get annoyed by the "Permission denied" and "No such file or directory" notice, smth like that: johndoe@johndoe-desktop:/$ grep -rnP 'YII_CORE_PATH' ./ | grep -v ...
10
votes
4answers
4k views

Understanding pipe in bash

I dont quite understand how pipes work in bash. I know that it takes an output from one command as the input in another command. What an output is i can get because it's what the command prints out ...
8
votes
5answers
8k views

What does the linux pipe symbol “|” do? [duplicate]

Here is a command that sorts files in a folder in reverse order ls | sort -r What does the | symbol in that command do? What I'm really looking for here is high level (easy to understand) ...
8
votes
5answers
2k views

delete or rename a file with \r as the file name

I have a pesky little file whose name appears to be single character, and that character is a \r How can I delete this? This is what I get with ls -bl: -rw-rwxr--+ 1 root ...
8
votes
2answers
996 views

Making bash TAB completion more like cmd.exe [duplicate]

I wondered if theres a way to do rotational style completion in bash similar to the behavoir on cmd.exe, I've found it speeds me up in regard to entering commands