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

learn more… | top users | synonyms

1
vote
1answer
194 views

PS1 problem, cmd is looping

I've set PS1 to the following value: PS1="\033[0;37m[\033[1;33m\w\033[0;37m]\n\t \[[34m\]\u\033[0;37m@\[[34m\]\[[1m\]\h\[(B[m\] $" The problem is that any command spanning more than a line loops ...
1
vote
1answer
675 views

Creating an alias or function, need to be able to pass in a parameter

I want to wrap 3 lines of execution into an alias, but I also need to pass a parameter when I call it in terminal. Do I need to create a function for this? I'm new to this, but I know there are ...
1
vote
3answers
670 views

On a Mac, how can I group together commands I want run into a alias?

In my .bash_profile I have created alias to commands that I run often. What if I want to group together multiple commands together, and they should run in serial one after the other. How would I do ...
1
vote
1answer
442 views

When does mac/ubuntu use .bash_profile and/or .bashrc? [duplicate]

Possible Duplicate: Difference between .bashrc and .bash_profile Are they both the same type of file in terms of setting the bash terminal settings, and if no .bash_profile exists then it ...
1
vote
1answer
628 views

Multiple hops SSH tunnel

I need to open an ssh tunnel through to an oracle database port...after much fluffing around I cant seem to get it to work. Here is the scenario... My Machine --> host1 --> host2 --> ...
1
vote
5answers
3k views

Insert a newline in a perl -e statement?

Consider the following Perl one-liner: perl -e '$x; $y;' I'm executing this command in bash and I'd like to insert a newline (\n) between the ; and $y. I'd like to know how to do this in two ...
1
vote
3answers
998 views

Custom Vim Highlighting (only works with specific file types)

I have this in my vimrc: "on will override defaults set. Enable will allow you to set defaults." syntax enable ... "attempting to highlight specific keywords so it is easy to see in code." "see ...
0
votes
1answer
2k views

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

I'm trying to test my installation for Pickit 2 on my Mac for the first time and when I put in: pk2cmd -?v I get: -bash: /usr/local/bin/pk2cmd: cannot execute binary file How do I resolve this ...
0
votes
1answer
45 views

Script won't loop through files like planned

I got this script that loops through log files, but I changed something and it doesn't work: #!/bin/sh n= while true do fname="trace$n.log" [ -f "$fname" ] || break n=$(($n+1)) done ...
0
votes
1answer
69 views

Run a command on every file in a directory, changing the output name

I need to compile all of the C files in a directory into seperate outputs... see example gcc -Wall program1.c -o program1.out How do I do this?
0
votes
2answers
94 views

Different initial BASH prompt

This is somewhat of a cosmetic (and trivial) question, but I suppose it may be useful to others than myself. I've been playing around with the $PS1 variable in my ~/.bashrc, and I was wondering if ...
0
votes
2answers
512 views

How to permanently reset my $PATH?

I was trying to add something to $PATH and it went totally wrong. I now can't run any commands such as ls. I've looked at this answer ...
0
votes
2answers
949 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
1k 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
273 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
2k 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
251 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 ...
-3
votes
1answer
52 views

Scripting for table data in a file

I have the following data file, EMP.txt: SNO,NAME,GENDER,COMPANY,EMPID,SALARY,JOINING_DATE,PHONE_NO,LOCATION 1,sravan kumar,M,ibm,1095,20000,01-SEP-2014,7651523,HYDERABAD 2,Vijay ...
117
votes
9answers
56k views

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

Can I search history in bash and run the result?
106
votes
7answers
73k 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) ...
88
votes
7answers
84k 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 ...
69
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 ...
47
votes
2answers
73k 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 ...
31
votes
4answers
15k views

How to: Unlimited Bash/shell history?

Is there a way to define an unlimited history in Bash ?
83
votes
10answers
53k 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 ...
47
votes
10answers
32k 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.
32
votes
6answers
27k 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?
13
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 ...
26
votes
3answers
66k 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 ...
24
votes
3answers
25k 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 ...
41
votes
2answers
9k 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
16
votes
2answers
6k 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: ...
14
votes
2answers
26k 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 ...
38
votes
4answers
16k 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 ...
32
votes
2answers
10k 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 ...
17
votes
2answers
22k views

Environment variables in bash_profile or bashrc?

I have found this question [blog]: Difference between .bashrc and .bash_profile very useful but after seeing the most voted answer (very good by the way) I have further questions. Towards the end of ...
13
votes
14answers
24k 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. ...
47
votes
6answers
13k 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? ...
38
votes
3answers
60k 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 ...
21
votes
1answer
3k 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?
18
votes
5answers
9k 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.
13
votes
3answers
25k 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 ...
26
votes
2answers
15k 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 ...
22
votes
4answers
13k 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.
43
votes
5answers
38k 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
50k 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 ...
9
votes
4answers
29k views

Using Wget to Recursively Crawl a Site and Download Images

How do you instruct wget to recursively crawl a website and only download certain types of images? I tried using this to crawl a site and only download Jpeg images: wget --no-parent --wait=10 ...
30
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 ...