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

learn more… | top users | synonyms

2
votes
1answer
353 views

open file from Cloud9's terminal (bash) in its IDE

What command would open a file in the default editor of Cloud9's IDE from within its own terminal bash shell? I tried xdg-open and gnome-open but those opens in emacs.
5
votes
4answers
4k views

SQL like group by and sum for text files in command line?

I have huge text files with two fields, the first is a string the second is an integer. The files are sorted by the first field. What I'd like to get in the output is one line per unique string and ...
1
vote
2answers
24 views

bash requesting password on every invocation of sudo

Within a single bash session I am repeatedly re-running a command prefixed by sudo. Typically the password should be requested once and then cached. However, the present behavior is that the password ...
7
votes
4answers
200 views

Is there any in-built Linux command to display the contents of a directory in real-time?

Is there any in-built Linux command to display the contents of a directory in real-time?Similar to the "tail -f file_name" command which displays the contents of a file in real-time.
6
votes
4answers
11k views

How do I change my default shell to bash if I don't have access to chsh nor /etc/passwd?

I'm working on a university remote Linux account, and the default shell is sadly csh without tab completion. How can I change my account's default shell to bash? chsh is not available.
0
votes
2answers
3k views

“Reset” colors of terminal after ssh exit/logout

When I ssh into a remote server, I like the colors of the terminal to change. I use setterm on my remote ~/.bashrc file to get this done. However, when I exit, the terminal colors are not reset to the ...
0
votes
0answers
15 views

How to fix Kali after power-loss during installation

I am trying to learn Kali-Linux and wanted to enable VPN. The menu was grayed-out, so I googled for a solution. blackmoreops.com told me to run aptitude -r install network-manager-openvpn-gnome ...
0
votes
2answers
27 views

Bash: effect of running `set -i`?

Today I was reading through the documentation of set, when I realised that my flags variable ($-) contained a flag undocumented on the help page (help set) and on GNU.org: i. After some time I managed ...
1
vote
2answers
288 views

how to use fzf on Mac Terminal with bash

I found a utility called fzf https://github.com/junegunn/fzf which is a fuzzy-finder for your shell. Two questions: 1) After I run fzf and run a file, I press Enter and then the file I found is ...
0
votes
0answers
16 views

emacs can't create new files (linux)

In bash, I can usually create a new file and open it using $ emacsclient -n -c test123 (assuming an emacs process is already running) However, after the most recent Arch-Linux upgrade it doesn't ...
0
votes
0answers
75 views

Login script for Asus router to automate the login process to Tikona ISP

I am using Tikona ISP (India) for my internet connection. It uses captive portal for log in process. But after few minutes of inactivity it automatically logs out. I am using Asus router RT-N14UHP. It ...
0
votes
2answers
134 views

How can I delete the content between two tags in a large xml file (>2GB)

The File in Question is XML but I want a Shell Script to remove all the binary (Base64) encoded images that are embedded. The files are generally huge (>2GB). I want to delete everything between: ...
0
votes
1answer
67 views

How to send a file to another computer with bash script?

I know that you could use sftp to send a file, from the command line - but I don't know how to do this in a .sh file. Is there a way to do this is one line, or many lines, as long as it's possible in ...
4
votes
7answers
5k views

grep count multiple occurrences

Is it possible to do a grep count of multiple occurrences in a file in one single command? For example: $ cat > file blah alfa beta blah blah blahgamma gamma I can do: grep -c 'alfa' file 1 ...
3
votes
3answers
3k views

Terminal pager: How to display a list in columns?

I'm sure it's very simple, but I can't remember how to tell a terminal pager (more/less/pg/most) to display a long list in columns. Since my input is just a list of short elements, displaying it the ...
0
votes
0answers
22 views

unexpected EOF while looking for matching `"'

JACOB=192.168.1.66 ZAC=192.168.1.65 echo "Type someone's name, or type ? to list options." read OPTNAME if [ $OPTNAME = "?" ]; then echo "Jacob's Computer: Type 'JACOB'" echo "Zac's ...
1
vote
0answers
43 views

How to kill process in bash? [migrated]

I used the following bash code: for pid in `top -n 1 | awk '{if($8 == "R") print $1;}'` do kill $pid done It says: ./kill.sh: line 3: kill: 29162: arguments must be process or job IDs ./kill.sh: ...
14
votes
2answers
18k views

How do I enter a literal tab character in a bash shell?

For example, I wanted to use the sort utility with the -t option to specify tab separators, but sort -t "\t" doesn't work.
2
votes
2answers
105 views

pip not working on hombrew python 2.7 install

I've installed python using homebrew and I can't invoke pip from the bash. I've tried amending my .bash_profile to include /usr/local/bin/python and /usr local/share/python to no avail. When I use ...
1
vote
2answers
30 views

Script answer to apt-get request “To continue type in the phrase 'Yes, do as I say!'” in bash

My script is replacing sysvinit with systemd inside a chroot while building a debian image with debootstrap. Since this is a "dangerous" action, apt-get will ask a silly question: "To continue type ...
11
votes
8answers
13k views

How to write a script that accepts input from a file or from stdin?

How can one write a script that accept input from either a filename argument or from stdin? for instance, you could use less this way. one can execute less filename and equivalently cat filename | ...
4
votes
4answers
477 views

How to limit CPU consumtion of a process group with standard GNU/Linux tools?

I have a bunch of processes of the same name - they take up 100% of my CPU time, I want this to be no more than 50%. How can I do this without installing any extra software?
3
votes
1answer
69 views

convert timezone of timestamp string in bash

I have a date/time string which is extracted from a filename. I know that the timestamp was written using time zone A and I need to convert it to time zone B for further processing. Is this possible ...
0
votes
1answer
34 views

How would one pipe from socat to sed to bc to xargs?

I have a server outputting some numbers, I'm reading them with socat, then using sed, I turn those numbers into some math equations, I run them with bc, then I need to pipe them into xargs. socat -u ...
0
votes
1answer
66 views

Script that scans my network

I have a question I want to run a script that scans my network and that I can see with devices are up in my network. I want to paste some arguments also in the script When I run the script: ...
0
votes
1answer
25 views

rsync variables script syntax error

Really struggling with getting a command argument variable to work with rsync. The behavior i'm seeing is this error from the script: rsync: connection unexpectedly closed (0 bytes received so far) ...
0
votes
1answer
26 views

Parse csv file and for each object set as a variable

What I'm trying to do is parse a csv file that has server names and ipaddresses and assign these to variables I then run commands using each set of variables. So if the cvs file, test.csv, looks like ...
1
vote
1answer
28 views

Bash -gt: unexpected operator

I have a checkSpace.sh which check the used space on a disk and if is greater than 80 stops a service #!/bin/bash percent=sudo df /media/usb | tail -n 1 | grep -E [[:digit:]]+% -o | grep -E [1-9]+ ...
0
votes
1answer
44 views

How do I run Asterisk as user other than root?

I compiled Asterisk 11 from source as user root on CentOS. Now I want Asterisk to run as user asterisk group asterisk. I have uncommented AST_USER="asterisk" AST_GROUP="asterisk" in ...
0
votes
1answer
29 views

How would I write this VIM command for `sed`?

I have a .csv with special characters that are wrecking an import I need to do. In VIM, I discovered away to remove the special characters with : :%s/\r//g This removes ^M from some of my broken ...
2
votes
2answers
1k views

Run a remote script/application in detached mode in Ansible

I am having trouble running a remote application startup script "detachedly" from an Ansible playbook. The script will run, but I can't get it to get/stay detached. I am probably doing something ...
11
votes
4answers
3k views

Bash history loss

I like to keep a lot of history, so I have histappend set in my .bashrc. Most of the time everything works fine, with history built up from many shells appending. However, every once and a while, I'll ...
5
votes
1answer
40 views

cd <nonexistent_directory> in bash causes cd to different directory?

Ok, so I've been using Linux for 18 years and have never seen or heard of anything like this: starting-forth$ ls ch01/ ch02/ ch04/ ch05/ ch06/ text/ starting-forth$ cd ch07 # A directory I ...
3
votes
3answers
262 views

Custom prompt doesn't work on Mac Terminal

I like to use a custom prompt (current path in blue) on my unix machine: export PS1='\[\e[0;34m\]\w \$\[\e[m\] ' But when I try to use it on Mac's terminal it doesn't work: it fails to detect the ...
59
votes
5answers
117k views

Where to find the .bashrc file on Mac OS X Snow Leopard and Lion?

I want to install rvm on my Snow Leopard machine. It says I need to add a line to my .bashrc file (I'm using bash) but where is my .bashrc file?
1
vote
1answer
911 views

Add milliseconds to existing Unix time

I have a script that returns Unix time in seconds, for example, 1374521719. I'd like to take in this time and place milliseconds to that. Other posts show a simple example of this with the current ...
0
votes
2answers
31 views

Copy files using a pattern or wildcard

I'm trying to copy all files like this: ... dialogue022-en.txt dialogue023-en.txt dialogue024-en.txt ... into files like this: ... dialogue022-pivot.txt dialogue023-pivot.txt dialogue024-pivot.txt ...
1
vote
4answers
3k views

How to disable trackpad/mouse via the Mac OS X command line?

Is there a terminal command in Mac OS X to disable/enable the trackpad/mouse? I know that I can disable the trackpad of my MacBook Pro when an external mouse is connected. But is this also possible ...
0
votes
1answer
20 views

Can bash reverse history search (Crtl+R) be configured to NOT delete history?

I find Ctrl+R very useful, however I am really anoyed that when I press the backspace key, it deletes the currently matched entry in the history. Is there a way to disable this ?
41
votes
5answers
12k 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? ...
1
vote
1answer
110 views

Terminal new window always shows -bash: Searching: command not found

When open terminal, it always shows -bash: Searching: command not found. It does not affect other functions, just each time, even though open a new terminal window, it still pops up at the top of the ...
32
votes
3answers
3k views

Have a file named ~ (tilde) in my home-directory

I just noticed that I have a file called ~ in my ~-directory. $ ls -la ~ ... -rw-r----- 1 x1 x1 733962240 Mar 1 17:55 ~ ... Any idea how I can mv or rm it?
5
votes
3answers
6k views

BASH - merge directories when using mv

I just started using BASH, so I can move all contents of a directory to another. But the issue is, I was expecting it to merge the directories. I am using cron job to run this script. #!/bin/bash ...
13
votes
6answers
6k views

Equivalent to ^D (in bash) for cmd.exe?

Is there an equivalent key-stroke for exiting a command prompt on Windows (launched via Start->Run : cmd) to the bash standby of Ctrl-d to prevent needing to type exit to leave the shell?
2
votes
3answers
315 views

Disable numlock, preserving mouse button key bindings

I'm having trouble to disable the Numlock key (make the key do nothing, so that the numpad numbers always work) while at the same time mapping extra mouse buttons (at the side of my mouse) to ...
2
votes
2answers
47 views

When typing in a command, my terminal will often times wrap around

So I'm having a really weird terminal problem that affects both physical login sessions as well as sessions over SSH. Basically, the terminal size is some number of columns. When printing stuff out, ...
2
votes
2answers
187 views

How to check if a file exists after a specific interval of time

I want to check if a directory contains a file (for example sample.txt). If it doesn't contain that file in 5 hrs then I would need to perform some action. How can I do this in a script? I tried ...
2
votes
3answers
2k views

Bash: number of seconds till midnight of current day

How do I find the number of seconds till midnight of current day?
0
votes
1answer
36 views

Matching () with a Unix/Linux regex

I have a couple files with the name (a).1 (a).2 ... (a).100 Since a lot of processing tools don't really like ( and ) in the filename I thought it best to rename them to a different name. I googled ...
0
votes
1answer
24 views

what the “!” means in the iptable rule

what the "!" means in the following iptable rule iptables -I inacc ! -i br0 -p UDP --dport 69 -j ACCEPT I think is related to the interface br0. I think it mean any interface except the br0 Am I ...