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

learn more… | top users | synonyms

12
votes
2answers
408 views

Difference when using backticks in double quotes and single quotes in Bash

Why to the following two executions differ in output? (I need double quotes for variables in my eventual command) $ sudo su -c "echo `cat /root/root_file`" cat: /root/root_file: Permission denied $ ...
5
votes
2answers
1k views

Change directory cd to another terminal's cwd

I would like to create a command like cd - (lets call it cdp) that will change directories to the last changed-to directory from another terminal window similar to the option to open a new terminal in ...
1
vote
1answer
34 views

bash complete: list directory names from a defined directory?

I need the directory names in /mailman/lists to tab-complete as an argument (without any slashes) to the 'list_members' command regardless of where I am in the filesystem. In tcsh (on our old ...
1
vote
3answers
2k views

Loop through a directory unix shell programming

Use a for loop to go through the filenames in the directory. In this version, only loop through the filenames that do not have a ".old" extension Inside the loop, rename the file to the new name.
1
vote
1answer
40 views

How to delete duplicate files of two folders?

I'm just getting to grips with the Linux Terminal but I still make mistakes: I recently erroneously managed to copy all of the files contained within a directory (including all sub-directories) into ...
0
votes
0answers
7 views

Changing Git Location on Mac OS X

I have a version of Git (1.9.3) already installed on my computer at /usr/bin. This version was installed (if I remember correctly) by XCode. I would like to install 2.2.1 (the download version from ...
0
votes
1answer
23 views

Prompt for values until press ENTER key with empty value

I'm working in a bash script for automatize some tasks. This is what I have done until now: #!/usr/bin/env bash PS3='Please enter your choice: ' options=("Create new group" "Add users to group" ...
7
votes
3answers
175 views

Why can't I kill this process on Linux?

Problem I would like to kill a process called raspivid (program which records videos using a Raspberry Pi Camera) but I cannot... This is how I call it: #!/bin/bash #Start recording... raspivid -w ...
0
votes
1answer
24 views

Can I automatically run commands after Linux Mint Installation?

That's what I want: I want to run a bash file (composed mostly by apt-get's and instructions to download and install .deb files) just after, or during, Linux Mint installation. I've found many ...
0
votes
2answers
29 views

How to find files created between hh:mm and HH:MM for any day?

For instance, find all files created between 20:00 and 23:30 for any day (not a specific day)? been going through man find and didn't see anything that would do this. Would I have to write my own ...
2
votes
1answer
688 views

tar: Cannot create symlink : File exists

I backup lots of gigebytes files in to myproject.tar.gz, and compress success without errors. Now, I want to decompress all to an folder "myprojects". adan@adan-Latitude-D630:~$ tar zxf ...
1
vote
2answers
68 views

Bash: can't type 'e' or I'll get infinitely repeating 'H's

At my workplace, there are several independent networks I work with, all running various versions of RedHat Linux 4, 5, and 6. On one of those networks, I can't use bash (or, as I'm finding out, ...
0
votes
1answer
46 views

bash command in python not working

I would like to run a bash command from python. My code: process = subprocess.Popen(('ifconfig -s'), stdout=subprocess.PIPE, shell=True) output = process.communicate()[0] lcd.message(output) sleep(2) ...
0
votes
0answers
17 views

How can I format the piped and refreshing output of multiple cmmands nicely?

I have a command line of multiple piped commands which executes beautifully in bash. For simplification: command1 | command2 | command3 Each command generates output while running, resetting the ...
0
votes
1answer
25 views

How can I make shell autocomplete the beginning of a filepath?

I have a project with a deeply nested folder structure. Most of the time I know the name of the file I want to work with, but the folder path is too long/complicated to type when I want to edit it, ...
0
votes
0answers
12 views

cntlm to use hash instead of password?

As my title says I want to add hash in my /etc/cntlm.conf instead of directly pasting the password. So I'm using sudo cntlm -H -c /etc/cntlm.conf command but it is leading to a prompt asking to enter ...
1
vote
2answers
2k views

Mac Terminal showing bash instead of my username

This makes it hard to know what directory I am in. I installed a version of python for school and now it says -bash-3.2$ instead of MyMacbook: ~$. I'm sure this is really simple, but I know nothing ...
1
vote
2answers
27 views

Expanding tilde convenience paths when using quoted paths in a bash script?

I have always used paths that aren't hardcoded inside quotes for my bash scripts. That way if the path (user inputed, user home dir, etc) happens to contain weird chars or spaces or dashes, my script ...
0
votes
3answers
45 views

Is there a way to determine which user ran a command in bash history?

We work on CentOS servers available to over a hundred employees via SSH, each with their own login. Running a normal history bash command shows all of the commands ran by all of the employees, however ...
10
votes
8answers
11k views

How do I queue multiple files for copying on a Mac?

When I copy multiple files on a Mac, the system tries to copy them all at the same time. The problem is two-fold. First of all, when you select multiple files and copy them, they all go into one ...
1
vote
1answer
21 views

PID of background task is different to the listed task PID using ps

Note: I h ave moved this to stack-overflow, I think that is the right place: here I have a strange issue, I can't quite get my head around. What I do is run a function called fn_rundumper which ...
1
vote
0answers
12 views

Bash partial glob expansion

I have a question similar to this one, but different: I want bash to use a glob expansion in auto-completion, if possible. For example, I would like $ ls *2.<TAB> To give me: $ ls mydoc2. ...
0
votes
1answer
14 views

Delete old backups alike Apple Time Machine does

Time Machine saves hourly backups for the past 24 hours, daily backups for the past month, and weekly backups for everything older than a month until the volume runs out of space. At that point, Time ...
0
votes
1answer
209 views

iTerm/OSX Terminal: Change text margin from edge of window

Currently, I use iTerm on OS X. My terminal looks something along these lines: I came across this picture of a terminal setup on GitHub, and I wanted to imitate it: Specifically, I wanted to ...
0
votes
0answers
4 views

Use sfk list against only current directory (do not descend tree) or provide max-depth

The sfk list command does not mention any equivalent of max-depth. I want to use sfk-list in just a single directory or even better with an equivalent of max-depth Any way to achieve this? ...
8
votes
3answers
9k views

Check if any of the parameters to a bash script match a string

I'm trying to write a script where I want to check if any of the parameters passed to a bash script match a string. The way I have it setup right now is if [ "$3" != "-disCopperBld" -a "$4" != ...
-1
votes
1answer
39 views

How to run remote linux command that won't stop after closing shell

There is a Linux terminal command that I want to run on a remote machine. I can ssh to the machine and begin executing the command (it's output being directed to an output file); however, once I ...
5
votes
3answers
744 views

Is it wasteful to call cat?

I’m sorry if this question is really stupid, but this is basically what I have been thinking about constantly. Suppose I run: : cat ./somefile.txt A few hundred times a second. How much faster is ...
0
votes
2answers
24 views

Combine the results of a CAT and TAC in a single window in Linux

I have two log files which I would like to view on my screen simultaneously. Below you can see my commands: pi@raspberrypi ~ $ watch -n 1 tac /home/pi/log/log.txt pi@raspberrypi ~ $ watch -n 1 cat ...
1
vote
2answers
48 views

Does Bash have cache of executables?

I was just writing a C++ program on my Ubuntu 14.10 computer. As it is a client/server program, I has three terminal emulators open: one for writing code and compilation, one for client testing, and ...
1
vote
1answer
67 views

Why does root cron job script need 'sudo' to run properly?

I'm running this simple script on my Raspberry Pi to auto update so I can forget about it. It also keeps a log that says whether the update was successful. The script is update.sh: #!/bin/bash echo ...
0
votes
0answers
49 views

bash doesn't find “./file” altough file is in current directory

This tells me that there is a file called arm-uclinuxeabi-gcc in the current directory: manuel@manuel-VirtualBox:~/linux-cortexm-1.12.4/tools/arm-2010q1/bin$ ls -l total 16808 -rwxr-xr-x 1 manuel ...
0
votes
2answers
415 views

Automated sudo and screen command

I would like to be able to launch a script in a separate screen command session as a separate user when I run a .sh script. Here is what I think it may be in the script: #I am also starting xampp ...
1
vote
1answer
38 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 ...
7
votes
6answers
9k views

Linux command to find files changed in last n seconds.

I would like a Linux command to find files changed in last n seconds. Is there a shell script or other tool that I can run from command line interface or gui?
0
votes
0answers
14 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 ...
1
vote
2answers
463 views

Upgrading Chromium OS to Chrome OS mount error

I'm trying to upgrade Chromium OS to Chrome OS with http://goo.gl/4suhf. Unfortunately, when running this script (inside Chromium OS), it says: wget stuff unpacking zipfile RootFS Start: 286720 ...
3
votes
1answer
115 views

Is it possible to check which stream is used by the command? (bash)

I have an irritating problem: redirecting stderr does not work. I get: iptables: Chain already exists I can't be bothered to check if a chain exists already (pointless, iptables just throws an ...
5
votes
3answers
5k views

remove first line in bash

Do you have a method to quickly remove the first line of a file in bash shell ? I mean using sed or stuff like that.
1
vote
1answer
39 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 ...
38
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
1answer
16 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: ...
0
votes
0answers
21 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 ...
0
votes
3answers
47 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 ...
2
votes
1answer
134 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
1answer
174 views

Drush commands not found when called from a bash script

Relevant system background: I'm using MAMP on OSX. Output of which php is /Applications/MAMP/bin/php/php5.3.14/bin/php Output of which drush is /Applications/MAMP/bin/php/php5.3.14/bin/drush Output ...
0
votes
0answers
16 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
36 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
1answer
29 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 ...
63
votes
7answers
65k 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 ...