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

learn more… | top users | synonyms

3
votes
3answers
15k 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?
3
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 ...
3
votes
1answer
763 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
596 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
290 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
105 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
140 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
141 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
893 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
5answers
3k 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
1k 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
469 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
848 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
1answer
712 views

Bash autocomplete paths “through” environmental variables

I used to be able to type cd $home/p hit the tab key and the command would change to cd /home/phill Now it doesn't. When cd'ing to a directory based on an environmental variable, I'm "flying ...
2
votes
2answers
705 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
305 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
2answers
3k views

How list file by range of date?

I would like to list files with 3 days years old. I found this one at stackoverflow: find . -type f -printf "%-.22T+ %M %n %-8u %-8g %8s %Tx %.8TX %p\n" | sort | cut -f 2- -d ' ' | grep 2012 But I ...
1
vote
3answers
716 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
3answers
549 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 / ...
1
vote
4answers
1k 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
62 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
74 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
3answers
417 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
375 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
84 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
2k 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
153 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 ...
9
votes
4answers
6k 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 ...
9
votes
4answers
3k 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
1k 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
2answers
759 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
8
votes
2answers
3k views

Spawn New Cygwin Window from Within Cygwin

I can't figure out how to launch a new Cygwin session from within Cygwin, similar to launching a new terminal from within bash with: gnome-terminal It's probably easy but I am missing something. ...
7
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 ...
7
votes
2answers
2k views

Linux: coloring bash prompt will break carriage return

When I try to colorize the bash prompt like this: export PS1="\e[0;31m[\u@\h \W]\$ \e[m " it breaks the carriage return (instead of going to a new line when line is full, it starts in the same line ...
7
votes
3answers
1k views

futurama bash scheme

Is there a color scheme for the BASH shell that matches the blackboard colors on futurama? (If it matters, I'm on OSX.)
6
votes
4answers
1k 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' ...
6
votes
7answers
6k views

Linux: rename file but keep extension?

In Windows/DOS, I can say rename myfile.* yourfile.* to change the name but keep the extension. How is that accomplished on Linux? The man page only suggests how to change the extension, but that's ...
5
votes
2answers
168 views

Differences in bash scripts between $@ and $*

Which are the differences between $@ and $* ? For example I see no differences here: #! /bin/bash echo with star: $* echo with at sign: $@
5
votes
3answers
356 views

How do I detect when I a terminal gets focus in Linux?

I want to be able to time how long I spend in front of a terminal. I'm thinking the best way will be to have some sort of timer that starts and stops when the terminal gains/loses focus. And it will ...
5
votes
2answers
7k views

Write a PID file manually from Bash script

How could I write a Bash-script that runs a long running program and stores the programs process id in a separate file? I want something like #!/bin/bash exec long_running_tool echo `ps af |grep ...
4
votes
3answers
2k views

Sublime Text Editor command not found

I have installed Sublime on my Mac Lion Laptop, and followed the guide here http://www.sublimetext.com/docs/2/osx_command_line.html but as always it did not work. I dont have a ~/bin directory on my ...
4
votes
3answers
4k views

What is the difference between Linux (Ubuntu) and Mac shell commands?

I use Ubuntu at work and a Mac at home. I was trying out some shell commands on my bash terminal on the Mac today but they didn't work. I was told both machines should operate UNIX commands so the ...
4
votes
1answer
590 views

how to move around files using “ls -al” result in Linux?

How can I write a script to copy files from one directory to another directory according to last modified date? ls -al -rw-r--r-- 1 user user 100 2011-05-26 12:33 ...
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?
4
votes
2answers
365 views

on quit, 'less' does NOT clear its contents when run in a 'screen' session [duplicate]

Possible Duplicate: Using screen, commands like less and man don't clear the screen afterwards When I quit 'less' in a normal bash, it clears the previous contents displayed by 'less' ...
4
votes
3answers
338 views

/usr/bin/reset disables backspace

Following this question, running /usr/bin/reset destroys my backspace functionality. What can I do? After pressing backspace I get ^?
3
votes
4answers
161 views

Terminal: prefix previous command?

Frequently in Terminal (though I fully expect any answer will work in bash and most others), I type some command, and then get some sort of permission error due to missing sudo. Okay, so press 'up', ...