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

learn more… | top users | synonyms

1
vote
1answer
19 views

$HOME is not defined for root user on Ubuntu 14.04

On a fresh Ubuntu 14.04 install, the bash environment for the root user does not have $HOME defined. I need to run some apps from a root shell, for example: gdb /usr/sbin/apache2 This is difficult ...
1
vote
1answer
12 views

SSH hanging after accepting public key

I'm getting strange behavior from ssh. I'm trying to log in to an ssh user named 'nfs' (e.g. ssh nfs@example.com) and it accepts the public key, but hangs. The contents of ssh -vvv immediately ...
0
votes
0answers
18 views

Screen: user session closed, why?

For a couple of years now have been relying on a bash script that invokes a java server process via screen; until last night it has run flawlessly, just ssh into remote server >> sudo screen >> invoke ...
1
vote
1answer
17 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 ...
0
votes
3answers
35 views

Why isn't & working?

So I ran the command find / .bash_profile to see if it existed anywhere on my Mac before I create one. Searching the entire computer obviously takes a minute, so I wanted to run it in the background ...
0
votes
1answer
16 views

OS X command to make current terminal window full screen

I am trying to make a bash script to open up my working environment. I want 1) Open up Terminal.app and type a command like "time_to_work" 2) This command will: a. open up sublime text open ...
0
votes
0answers
15 views

Possible to su and run both .bash_profile's?

I currently log into the boxes at work, then: su - <adm_user> My question is, is it possible to pass through to the su'd user, my bash profile and source the adm_user's bash profile?
0
votes
1answer
13 views

OS X LoginHook - nc exits prematurely for no apparent reason

I'm trying to use loginhook to download large amounts of data and I've been having problems which I've nailed down to nc exiting prematurely for no apparent reason. This is a simplified test script: ...
1
vote
1answer
15 views

How can I force gnuparallel to carry out a command set sequentially?

Gnu parallel is a powerful tool that I use to run many independant BASH commands as a single set in parallel. I would like to be able to run the same commands SEQUENTIALLY without significant changes ...
0
votes
1answer
20 views

SSH - Ignoring $PS1 in .bashrc

Relevant file contents: http://pastebin.com/6VtWcaWG Everything else including the aliases and the PATH variable are fine, but when I log in as root on my remote machine, the correct $PS1 (set in the ...
0
votes
1answer
6 views

Reverse a default flag

As a context. I have a folder which I have symlinked into my $HOME directory. ~> ls -s /var/www/to_link "$HOME/linked" I cd into "$HOME/linked" So, by default, pwd shows the current directory ...
1
vote
1answer
22 views

grep: output specific line after match

Is there a way, using grep, to output the line that falls a specific number of lines after the match is found? For example, I want to output the line with a match, the 8th line after the match, and ...
0
votes
2answers
20 views

use sed to replace part of a string

I am planning to replace certain strings in a file; so I am using sed. I would like to have the string replaced, while instead, sed read the string and append the text in the middle of the string. ...
2
votes
2answers
15 views

Script to check for files newer than argument, help using -nt [on hold]

I'm trying to make a script that shows files in the directory newer than one given as an argument, but I seem to be running into a problem. Currently I have: for f in *; do if [["$f" -nt ...
0
votes
0answers
9 views

Ruby RuntimeError on launching terminal (Mac)

Whenever I open the terminal on Mac I get this error: /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby: invalid option --1 (-h will show valid options) (RuntimeError) ...
1
vote
1answer
25 views

How is bash's * passed to a program?

When I type evince * in a folder with a lot of pdfs, what is sent to evince? Does evince receive X arguments, or are X occasions of evince opened, each one getting one argument (a single file)?
1
vote
2answers
17 views

why 'export $Path=$Path:dir' won't work?

I am just wondering why do we need to use this command export Path=$Path:dir why does the command not look like export $Path=$Path:dir/dir'
1
vote
2answers
24 views

Linux: How to kill a root owned process by parameter's name?

I would like to know how to kill processes owned by the root based on their parameter's information: root 3176 0.0 0.8 3604 2252 ? S 21:33 0:00 sudo python main.py root ...
0
votes
0answers
13 views

Error while using sudo apt-get update

I am using ubuntu 12.04 and while using sudo apt-get update command I get this error: Hit http://in.archive.ubuntu.com precise-backports/universe Translation-en Fetched 4,683 kB in 1min 14s ...
0
votes
0answers
13 views

Odd 7z Extracting Behavior

In short, I would like to use command-line 7z to extract an archive and recreate the directory structure of the archive. I know the function letter for this is "x" yet it does not seem to work for ...
0
votes
1answer
25 views

Why grep shows me output that does not contain the search word?

I want to check if the sensu service is installed. I ran this command service --status-all| grep sensu and here is the output vagrant@vagrant-ubuntu-trusty-64:~$ service --status-all| grep sensu [ ? ...
0
votes
0answers
16 views

accessing remote web-pages from local computer

Suppose I can access my remote computer from the console putting (using OSX) ssh my_name@my_ip Suppose now I want to visit web pages of the remote computer, and this from my local only using the ...
1
vote
1answer
22 views

chmod throws missing operand on 764, OK on 664

Having set everything in my project to 777 (rwxrwxrwx) for debugging purposes, I wanted to dial down the openness and set the directories (not the files) in the root folder to 664 (rw-rw-r--). To do ...
1
vote
0answers
25 views

Gnu screen, using the exec command in .screenrc

I have added the following lines to my .screenrc bind -c music u exec amixer sset Master,0 5+ >& /dev/null bind -c music d exec amixer sset Master,0 5- >& /dev/null bind -c music t exec ...
0
votes
1answer
22 views

How do I configure easy_install to use the right Python interpreter?

I am using mac OSX and have installed python 2.7.9 via this article, from /usr/bin if I run the command ls -l /usr/bin/python* in a bash terminal, I get lrwxr-xr-x 1 root wheel 67 Jan 24 02:12 ...
0
votes
0answers
10 views

SImple server to run program and return result

I am attempting to create a minimal local listen server that takes an input request, pipes the input to a program and then returns the result of the command. What I have at the moment is the program ...
0
votes
1answer
15 views

How to call in one line multiple processes in serie

If I run the following script with 3 lines: process1 process2 process3 then process2 will wait for process1 to start, and the same will happen with process3. How can I do the same in only one line ...
1
vote
1answer
31 views

Environment variables on Linux-like systems

How to set environment variables for a user in most generic way that is independent of shell environment variables (like profile for Bourne-like shells, bahsrc, zshrc, zshenv, ..)? The idea is to set ...
3
votes
1answer
26 views

How do I prepend a string to program output without waiting for the whole line?

I have a script that runs a command on a remote server using SSH. I want to prepend the string Remote: to every line of the output, but I don't want each line to be delayed until the whole line is ...
23
votes
2answers
1k views

Is there a one line command to make chmod interactive?

I am looking for something like: ls | ask_yes_no_for_each_file | chmod +x the_files_approved Or similar syntax. Also could work on other commands that you want individual confirmation for.
1
vote
1answer
37 views

Bash permission denied error on trying to source ~/.bash_profile

I can't work out why I am getting this error -bash: /dev/ttys000: Permission denied when I try to source my ~/.bash_profile? Nothing has changed in my setup (OS X 10.10.1), except a recent ...
0
votes
1answer
19 views

Open terminal with telnet from command

I'd like to open a telnet sessions from a sublime text build process. I've tried using open /bin/bash --args telnet 127.0.0.1 but that fails .. is there anything similar I can do? Edit I'm ...
3
votes
1answer
38 views

Bash “command” equivalent in PowerShell

Is there a "command" equivalent of Bash in PowerShell? I used to over-ride certain command in Bash like this: function npm(){ command npm --no-color $@ } I'd like to do the same in PowerShell, ...
0
votes
1answer
20 views

Can't type anymore on Git bash after returning from ssh -tt

I wanted to execute a command in a remote shell in its interactive environment, so as to make it load my remote .bash_profile there first before executing the command. This works great: echo ...
1
vote
1answer
31 views

How to grant execute access to a specific set of command to one group, and another set to another group

Say there is a set of shell commands {ls, cat, kill} I want to enable users in group A to be able to execute the commands {ls, cat} And users in group B to be able to execute the commands {cat, kill} ...
36
votes
9answers
3k views

How to quickly change the first word in a Bash command?

I would like to improve my workflow a bit with Bash, and I realize I often want to execute the same command to a different executable. Some examples: Git (where I would like to quickly change the ...
0
votes
0answers
16 views

Top -l returning always 0.0 CPU usage when requesting single PID

On Mac OS X 10.9 (Mavericks) & 10.10 Yosemite I’m unable to get the correct CPU usage for a single process using the top -l command for example top -l 1 -ncols 3 -pid <pid> Even though I ...
0
votes
0answers
29 views

Bash function only works when password manually input

At work I have to run the following function everyday. The function works fine when I am prompted for the password. However, I tried to hardcode my password so that I don't have to enter it in each ...
1
vote
1answer
30 views

Echo in file returns No such file or directory

I'm wondering why my simple script doesn't work: #!/usr/bin/env bash user_variable='$1' echo "export USER_VAR=$user_variable" > ~$user_variable/.filename When I launch the script I have this ...
0
votes
3answers
38 views

using awk on only files which START with 'xyz'

I have 3 files in a directory: xyz1.txt, xyz2.txt, rst_xyz.txt and I want to work with ONLY the first two (those which start with xyz). The command ls | awk '/xyz/{print $1}' will return all three of ...
0
votes
1answer
22 views

How to enable path folder in mac terminal

As You see when I put command "pwd" I'm in folder: MacBook-Grzeg% pwd /Users/Grzeg/ticket_managment But my terminal still show only that's: MacBook-Grzeg% Now as you can see I have ...
0
votes
1answer
17 views

CentOS bashrc function to email on login

I've a system setup where an email is sent on a user login (line from .bashrc): printf "user details, ip etc" | mail -s "[LOGIN NOTICE] `hostname` - `whoami`" <admin>@<domain>.co.uk ...
0
votes
0answers
14 views

Is it possible to reuse functions I defined in .bashrc from zsh?

I am using bash on my Mac and I spent a lot of time customising functions in there. One things stops me from adopting zsh fully on Mac: I am not that proficient in zsh so I am pretty sure I can ...
0
votes
1answer
39 views

iTerm/zsh not reading .bashrc OR .bash_profile

In ~/.bash_profile I have : if [ -f ~/.bashrc ]; then source ~/.bashrc fi In ~/.bashrc I have some aliases When I load a new iTerm window, my aliases do not work. If I source ~/.bashrc they ...
0
votes
4answers
70 views

How do I DELETE a comma and a space from a numeric string using a bash script

Folks, I have asked this question 5 times on here and have received 5 separate bits of code from super users that have all *failed. Problem: I have stock information being brought back into a txt ...
4
votes
3answers
179 views

Execute command in-between a bash pipe row …?

I want to run a series of piped commands which do a lot of audioprocessing. It looks as follows in pseudocode: command1 | command2 | command3 Of command2 and command3, both take the output of the ...
1
vote
2answers
27 views

Removing file and all links - hard and symbolic

How can I remove file and all links related to file to remove? rm -f file.txt removes just the file. Futher more, if there any other hard links of file system the file will not be removed. What is ...
2
votes
1answer
34 views

How to include hidden files in ls pattern match?

I was just trying to list files in the current directory with a certain pattern, but it doesn't work with hidden files. How can I match all the files? I tried ls *foo* and ls -a *foo* Not ...
2
votes
3answers
46 views

Linux mv command for moving multiple files with different extensions

I am wondering if it possible to use bash to mv multiple files with different extensions into one directory, for example mv 1.png 2.jpg dir/ except match many files
0
votes
0answers
16 views

Location of commands executed in past

With HISTTIMEFORMAT="%d/%m/%y %T ", history command shows the exact time of the execution of a command. Is there a way to find from which folder the command was executed?