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

learn more… | top users | synonyms

0
votes
2answers
883 views

How to use sudo with rcp command to copy files from linux host to HP-UX host?

I'm having this issue where when I try to use sudo to rcp some files from a Linux host to an HP-UX host (note that the destination directory requires root access to write to), I get the following ...
0
votes
2answers
981 views

using history command with ssh and getting output with time stamps

Basically i want to get a record of all commands executed on my ssh server, with their times. The codes i have tried are : ssh user@ip 'export HISTFILE=~/.bash_history; set -o history; history' I ...
0
votes
1answer
268 views

How to improve this bash shell script for turning hardlinks into symlinks?

This shell script is mostly the work of other people. It has gone through several iterations, and I have tweaked it slightly while also trying to fully understand how it works. I think I understand it ...
0
votes
4answers
1k views

Can I create a configuration file for a shell script?

Is it possible to create a .sh shell or .command file with a configuration file? I need to backup websites via Terminal and be able to put some data to configuration files, and have the shell execute ...
0
votes
1answer
202 views

How can I fix my custom PS1 to wrap a long command over multiple lines instead of a single line?

I'm trying to customize my bash prompt on Mac OS X. Here is what I put in .bash_profile: $ cat .bash_profile export PS1="\e[0;36m\u : \W \$\e[m " #... I got the prompt I wanted but when I enter a ...
0
votes
1answer
2k views

Create rar without directory structure from command line

I've got a folder full of folders, and some of those folders may or may not have folders in them. It looks something like this: ~/stuff/01.d/01/files ~/stuff/02.d/files ~/stuff/03.d/files ...
0
votes
1answer
1k views

Change Mac “Ask for password after screensaver” delay

How can I change my Mac OS X Snow Leopard "Ask for password after screensaver" delay? I've tried: defaults -currentHost write com.apple.screensaver askForPasswordDelay -int 3600 but won't work. I ...
84
votes
9answers
40k views

How can I search the bash history and rerun a command?

Can I search history in bash and run the result?
65
votes
6answers
4k views

How do I perform commands in another folder, without repeating the folder path?

Is there a clever way to do copy and move operations or a command to duplicate a file, without having to do a cd, then mv after, at the same folder? For example, I have to run the following: mv ...
97
votes
4answers
54k views

Why does Ctrl + V not paste in Bash (Linux shell)?

When I copy something to the clipboard and press Ctrl + V in Bash, nothing happens; However, right clicking and selecting Paste does the job. Why? Is there any reasonable issue (I'm sure there is) ...
62
votes
7answers
64k views

How do I add text to the beginning of a file in Bash?

Hi I want to prepend text to a file. For example I want to add tasks to the beginning of a todo.txt file. I am aware of echo 'task goes here' >> todo.txt but that adds the line to the end of ...
29
votes
4answers
16k views

Cygwin fatal error unable to remap.. What does it mean?

0 [main] python 6140 C:\cygwin\bin\python.exe: *** fatal error - unable to remap \\?\C:\cygwin\lib\python2.6\lib-dynload\time.dll to same address as parent: 0x2B0000 != 0x360000 Stack trace: Frame ...
25
votes
3answers
12k views

How to: Unlimited Bash/shell history?

Is there a way to define an unlimited history in Bash ?
29
votes
5answers
24k views

Mac OS X .bashrc not working

I have a one-line .bashrc file in my home directory: alias countlines='find . -type f -print0 | xargs -0 cat | wc -l' But it is not creating the alias. Why might that be?
70
votes
10answers
43k views

Is it possible to `tail -f` the output of `dmesg`?

Want to do something like dmesg | tail -f but it doesn't work: I use Mac OSX 10.6.7, by doing that the tail will exit, instead of monitoring the output. I wonder if there is any way to do it, or ...
41
votes
10answers
27k views

Unix: ls, how to sort first directories then files etc

I would like to use ls command to first show direcotries and then files. I tried ls -la | sort -k 1 But I got a wrong order.
26
votes
2answers
45k views

Bash: Display each sub-directory size in a list format using 1 line command?

I want to get a list of the directories and their sizes in a list format like how you get when you do a ls -l. The thing is that is there a one line command that can do this? I see others have long ...
10
votes
2answers
3k views

Binding backward-kill-word to Ctrl+w

I'm trying to switch from prolonged use of Tcsh to recent exploration of Bash. I've managed to port over all my favorite features, except for Ctrl+w which treats spaces and slashes as word ...
21
votes
3answers
21k views

How to join/merge many mp3 files?

Searching Google on how to join/merge many mp3 files, it suggests that I should just cat them together. That might "work", but clearly it is not the correct way to do it, as each header and set of ...
38
votes
2answers
7k views

how to expand aliases inline in bash?

Is there a way to expand aliases inline in bash? $bash>alias ll='ls -l ' $bash>ll<tab> $bash>ls -l
24
votes
3answers
56k views

Command: sudo su -

I understand what su - does logs you into root with the root environment (as opposed to su which logs you into root with your environment) And I understand what sudo does you are root for one ...
15
votes
2answers
5k views

Putty SSH: CTRL+Cursor keys don't work skip to previous/next word

When I am connected to my local Ubuntu dev server with putty (from my Windows 7 box) via SSH, the following key combinations don't work to move the cursor forward and backward on word boundaries: ...
35
votes
3answers
50k views

How can I change shell in Ubuntu? [duplicate]

I have a Ubuntu Server VPS and I want to use /bin/bash/ as my shell. How can I change my shell? I have root access but I don't work as root. So dash is my default shell now. I have read How do I make ...
33
votes
4answers
12k views

Bash: Spaces in alias name

I am trying to create an aliases in bash. What I want to do is map ls -la to ls -la | more In my .bashrc file this is what I attempted: alias 'ls -la'='ls -la | more' However it does not work ...
31
votes
2answers
9k views

How do I reload .inputrc?

Background I have heard that the readline module is reading ~/.inputrc and that is how it changes the behaviour of keystrokes under programs such as bash. Question How can I reload this after ...
10
votes
2answers
20k views

Open gnome terminal programmatically and execute commands after bashrc was executed

For starting my dev environment I wrote a little script. One part is to open a gnome terminal with several tabs where automatically some commands should be executed. Some of those commands depend on ...
17
votes
4answers
8k views

Bash/ZSH: Undoing 'disown'

Is there a way to 'reattach' a process to the shells job table after it it has been 'disowned'? Edit: $SEARCHENGINE totally fails me. Doesn't look too good.
11
votes
12answers
16k views

Monitoring a file until a string is found

I am using tail -f to monitor a log file that is being actively written to. When a certain string is written to the log file, I want to quit the monitoring, and continue with the rest of my script. ...
11
votes
3answers
22k views

Change DNS Server From Terminal (or script) on Mac OS X

How can I change my DNS server from the Terminal on Mac OS X? [I need this because my DNS is not working correctly with my VPN. Sometimes it's using the DNS for my main connection, and sometimes it's ...
29
votes
5answers
9k views

Is there a shortcut to mkdir foo and immediately cd into it?

This is something I do frequently $ mkdir foo $ cd foo This works as a single command, but it's more keystrokes and saves no time. $ mkdir foo && cd foo Is there a shortcut for this? ...
25
votes
2answers
13k views

Bash Shebang for dummies?

I have some bash scripts I have setup that mostly use #!/bin/bash but I regularly come across some that look like #!/bin/bash -e #!/bin/bash -x #!/bin/bash -ex and so on. Can someone explain ...
19
votes
1answer
2k views

How do I reload .inputrc using a bash script?

This question explains how to reload .inputrc using C-x C-r. But how would one reload it using commands in a bash script?
14
votes
3answers
17k views

I want to change DPI with Imagemagick without changing the actual byte-size of the image data

I feel so horribly sorry that I have to ask this question here, but after hours of researching how to do an actually very simple task I'm still failing... In Gimp there is a very simple way to do ...
28
votes
10answers
3k views

Prevent user typing accidental space between rm and wildcard

Intention: rm -rf string* Problem: rm -rf string * The first case is a legitimate and common use of rm, a small typo can cause a lot of problems in the second case. Is there a simple way to ...
12
votes
3answers
10k views

linux merge folders: rsync?

I have two copies of a folder src/ dest/ I want to merge them, doing the following: If a file is only in src, I want it to be moved to dest If a file is only in dest, I want it ignored IE left ...
10
votes
6answers
5k views

Running commands in parallel with a limit of simultaneous number of commands

Sequential: for i in {1..1000}; do do_something $i; done - too slow Parallel: for i in {1..1000}; do do_something $i& done - too much load How to run commands in parallel, but not more than, for ...
8
votes
2answers
26k views

How to find all soft links (symbolic links) in current directory?

Question relates to shell-scripting in bash. How to check with a script which files within the current directory are soft links? In case I have used the wrong term, when I say soft links, I am ...
26
votes
7answers
40k views

'No such file or directory' error in bash, but the file exists?

On Ubuntu, I get a 'No such file or directory' error when I try to execute a command. I have checked with ls -la , the file adb is there and it has 'x' flag So why I am getting a 'No such file or ...
13
votes
4answers
8k views

Newlines in sed on Mac OS X

I find that \n doesn't work in sed under Mac OS X. Specifically, say I want to break the words separated by a single space into lines: # input foo bar I use, echo "foo bar" | sed 's/ /\n/' But ...
9
votes
3answers
10k views

Passing two arguments to a command using pipes

Usually, we only need to pass one argument: echo abc | cat echo abc | cat some_file - echo abc | cat - some_file Is there a way to pass two arguments? Something like {echo abc , echo xyz} | cat ...
9
votes
7answers
59k views

ssh and shell through ssh : how to exit?

I'm launching a distant script through SSH like this: ssh user@ipaddress '~/my_script.sh' Everything is going fine but once the script is finished, the connection is not closed. I Have to press ...
7
votes
2answers
1k views

Bash Run command for certain time?

I am making bash script for my use. How can i run a command for certain time, like 20 second and terminate command? I tried a lot of solutions but nothing works, I also tried timeout command with no ...
7
votes
3answers
10k views

grep for “term” and exclude “another term”

I am trying to build a grep search that searches for a term but exludes lines which have a second term. I wanted to use multiple -e "pattern" options but that has not worked. Here is an example of a ...
37
votes
5answers
29k views

Change default text editor for crontab to vim

I'm using ubuntu 9.10 and the default text editor is nano, which i hate. (doesn't everyone?) Normally it's not a problem as i just vi or gedit everything but crontab -e is opening with nano. I ...
27
votes
7answers
45k views

tar: Exiting with failure status due to previous errors

I have written a little script that tars and compresses a list of directories + files. The script appears to run succesfully, in that a useable .tar.gz file is created after the script runs. ...
17
votes
4answers
10k views

Change Terminal Title in Mac OS X

How can I arbitrarily change the title of a Terminal window in Mac OS X? I have seen this question and this magicwrap thing, but think it's just a simple Mac OS X command.
16
votes
4answers
16k views

How do I convert a bash array variable to a string delimited with newlines?

I want to write out a bash array variable to a file, with each element on a new line. I could do this with a for loop, but is there another (cleaner) way to join the elements with '\n'?
7
votes
3answers
20k views

How to delete files on the command line with regular expressions?

Lets say I have 20 files named FOOXX, where XX is the number of the file, eg 01, 02 etc. At the moment, if I want to delete all files lower than the number 10, this is easy and I just use a wildcard, ...
6
votes
5answers
5k views

Clearing terminal

I would like to issue a command from a bash script to clear the terminal it is running from: I don't want to clear the bash history (history -c) I don't want to issue the clear command (which ...
6
votes
4answers
5k views

Bash: create anonymous fifo

We all know mkfifo and pipelines. The first one creates a named pipe, thus one has to select a name, most likely with mktemp and later remember to unlink. The other creates an anonymous pipe, no ...