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

learn more… | top users | synonyms

11
votes
1answer
23k views

How to permanently add current directory to PATH in Linux? [duplicate]

Possible Duplicate: Add folder to PATH I want to a add a directory to my bash to search in, and I am using the $PATH=.... it works however when I open a new command window it is not there. ...
10
votes
9answers
7k views

How do I copy file named starting with a dot?

I am trying to copy all files under directory A to directory B. All files under directory A are starting with dot, for example: A/.a A/.b A/.c which I found if I use: cp A/* B, always get error: ...
9
votes
6answers
7k views

Copy files in Linux, avoid the copy if files do exist in destination

I need to copy a /home/user folder from one hard disk to another one. It has 100,000 files and around 10G size. I use cp -r /origin /destination sometimes I get some errors due to broken ...
8
votes
6answers
5k views

Clear stdin before reading

I have the following bash script: # do some time consuming task here read -p "Give me some input: " input Now as you might have guessed, if a user presses some random keys during the "time ...
8
votes
5answers
2k views

bashrc: how to know X window is available or not?

There is a part in my ~/.bashrc, which sets $EDITOR to be gvim. It works fine when I am in X window. However, if I ssh to my workstation (from another workstation) gvim starts to complain "cannot open ...
8
votes
3answers
3k views

avoid permission denied spam when using find-command

I often try to find files with following syntax: find . -name "filetofind" However it usually results as many rows or error reporting (Permission denied) about folders where permission is denied. ...
7
votes
3answers
17k views

command not found when using sudo

There are a few question on the site that seem related to my problem but I could not find a solution in any of them. My operating system is Ubuntu 12.04. I have mvn installed in ...
7
votes
4answers
2k views

BASH history truncated to 500 lines on each login

For some reason, I cannot get my system to keep my BASH history after a reboot. Here are the relevant sections of my ~/.bashrc: shopt -s histappend PROMPT_COMMAND='history -a; updateWindowTitle' ...
7
votes
3answers
7k views

Use OpenOffice from command line to convert HTML to RTF

I'm trying to build a bash script in Cygwin that will convert HTML files to RTF. In OS X this is trivial with textutils, but that doesn't exist for regular Linux or Cygwin. Instead I'm trying to use ...
5
votes
3answers
3k views

Can I use pipe output as a shell script argument?

Suppose I have a bash shell script called Myscript.sh that need on argument as input. But I want the content of the text file called text.txt to be that argument. I have tried this but it does not ...
5
votes
5answers
2k views

Why does wget'ing an image give me a file, not an image?

I do wget http://services.runescape.com/m=itemdb_rs/3809_obj_sprite.gif?id=2 and it downloads the following file: 3809_obj_sprite.gif?id=2 How can I make it save as the following? 2.png
5
votes
2answers
5k views

Monitor a Folder OSX for file changes then run a bash script [duplicate]

Possible Duplicate: Watch Filesystem in Real Time on OS X and Ubuntu I'm looking for a efficient method to monitor a local directory in OSX and if any files have been changed in that ...
5
votes
3answers
5k views

Gnome: Change title of current terminal from bash command line

I know there are options to start a new terminal with a specified title, and that is is possible to change the title from a terminal using the menu: 'Terminal' -> Set Title. However, I want to change ...
5
votes
5answers
3k views

How to color grep output

When I type memcached -vv 2>&1 | grep --color=always "SET\|GET" I get nice memcached stats GET AR-City-1 GET rest-part-241 SET rest-part-241 Value len is 685 GET ...
5
votes
3answers
721 views

Is it wasteful to call cat?

I'm sorry if this question is really stupid, but this is basically what I have been thinking about constantly: Suppose I run : cat ./somefile.txt a few hundred times a second. How much faster is my ...
5
votes
5answers
2k views

What is the difference between “Shell” and “Terminal”?

I am fairly new to Ubuntu and I am loving it! But I don't quite understand the difference between the shell and the terminal. Can any one explain? Someone told me that a terminal is just a "tool" to ...
5
votes
1answer
562 views

Is there a way to preprocess input to bash?

I would like to be able to define arbitrary modifications to command lines that happen before bash sees them at all, ie, before expansion of any kind. Is this possible? I'm not trying to solve one ...
4
votes
1answer
326 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
2answers
2k views

How to persist bash history?

I don't know if this is expected, but my history is not saved across sessions. This is to say, if I close the window, then when I open it again, the history is empty. How can I persist it across ...
4
votes
3answers
203 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
17k 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
4k 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 ...
4
votes
3answers
6k views

Can't edit /etc/profile on my mac

In terminal, I do this: sudo vi /etc/profile But I get a read-only version. I've never not been able to edit anything as a super user- What's going on?
3
votes
3answers
217 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
3answers
1k views

Alert after long running shell script

When I have wait for slow commands (operations on large databases for example), I start doing something else and often don't notice for a long time that it has finished, wasting valuable time. I am ...
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
1k 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
862 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
136 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
789 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
616 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
307 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
119 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
150 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
152 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
1k 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
4answers
600 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
4k 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
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 ...
2
votes
1answer
490 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
996 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
795 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 ...
2
votes
1answer
309 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 - ...
1
vote
3answers
887 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 ...
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
1k 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
66 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 ...
1
vote
1answer
11k views

-bash: ls: command not found at Terminal on Mac OS X

I need to start using GIT for my projects from now on and I need to use some UNIX commands. but no matter what I do, I always receive "command not found" error. I installed MacPorts, but still cant ...
0
votes
2answers
86 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" ...