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

learn more… | top users | synonyms

1
vote
2answers
4k views

How to auto commit to my git repository using cron?

I look into a lot of answers about this subject, but something is wrong here, let me explain. I create this script, to make my cron cleaner :) #!/bin/bash cd ...
0
votes
2answers
20 views

bash - appending ' to end of command?

I stumbled across this by accident, and was wondering what it meant. What I did was I was typing adb logcat but accidentally typed adb logcat' and I was greeted to this: I Control-C'd out ...
1
vote
3answers
58 views

BASH: finding partition from diskutil output

I'm trying to search the output of a command listing local drives to find a partition called EFI on the boot HDD. I've written a really dirty oneliner as I can't seem to work out how to effectively ...
3
votes
2answers
218 views

How to properly restore settings when running a script using “source”?

I'm writing a script that needs to be executed using source, because its task is to modify the environment. During the script, I want to use set -e so that any error stops the script. The script looks ...
0
votes
1answer
23 views

bash - processing output one line at a time

I read that xargs was good for processing the output of a command one line at a time (and it is). I have the following line in my script. ./gen-data | awk '{printf $2 " "; printf $1=$2=$3=""; gsub (" ...
28
votes
5answers
15k views

How to keep only every nth line of a file

I've got a rather sizable CSV file (75MB). I'm just trying to produce a graph of it, so I really don't need all of the data. Rewording: I'd like to delete n lines, then keep one line, then delete n ...
1
vote
2answers
23 views

how to gzip and scp at the same time

I have a file in which i wanted to zip up and at the same time transfer over to another host using scp. I tried to do the following command but failed. I do not mind zipping up and scp over later, ...
1
vote
1answer
22 views

bash: Different results if same function is called from sourced script or executed directly

I've run into a something that I don't understand, and I've managed to reproduce the situtation in the script below. If I source the script it fails with head: 1: invalid number of lines. But if the ...
2
votes
3answers
831 views

Redirecting shell command outputs to another konsole shell

I am writing a shell script and I would like to write commands in the script but redirect the output to other konsole sessions. (using kde)
1
vote
0answers
22 views

Custom script in /etc/rc.local - not starting X properly

I made a script called starter.sh: #!/bin/bash while true; do sudo fluxbox & sudo -u pi epiphany-browser -a --profile ~/.config http://localhost/index.php & sleep 2s done; Which is ...
-1
votes
1answer
20 views

Trouble setting up the class path for MySQL and running MySQL via terminal

Question: what is the easiest way to run the MySQL app from the terminal What I have tried: Using some stackOverFlow suggestions I have used the following commands echo $PATH, produces ...
0
votes
1answer
40 views

Multiple Conditions in shell script

Im stuck in giving two conditions in my script. I can read two things - What is the NEAREST SERVER If it is MacBook or Anything Else and then use defaults write command to modify the plist file. ...
0
votes
1answer
316 views

shell standard streams redirection order OR 2>&1 1>/dev/null vs 1>/dev/null 2>&1

Can somebody please clarify differences? Is some of those considered as best practice? If I remember correct I somehow on SO read that this 1>/dev/null should precede this: 2>&1 ls -al ...
0
votes
1answer
17 views

How to use echo in shell command from Makefile?

I have a GNU makefile. It runs fine on Linux, Solaris and OS X. However, under Cygwin-32, Cygwin-64 and MinGW, it produces: /bin/sh: -c: line 0: syntax error near unexpected token `(' /bin/sh: -c: ...
2
votes
5answers
69 views

Any way to avoid dot-slash when running executable scripts in bash?

let's say I have a script. chmod +x myscript Now to run this I go ./myscript But is there any way I could just run it by typing myscript ???
0
votes
1answer
23 views

alias disables colour sustainably in bash

When I do tree -N I get nice coloured output. When I then alias tree="tree -N" tree output is black & white. When I then unalias tree tree -N output is still black & white! GNU ...
0
votes
2answers
36 views

How to store formed command line without running it in bash or terminal?

For example, I have formed a long complicated command that will improve the world and lower an entropy in the Universe. But then (huh!) I see that I forgot to make a dir required. I want to store my ...
13
votes
3answers
10k views

linux merge folders: rsync?

I have two copies of a folder src/ dest/ I want to merge them, doing the following: If a file is only in src, I want it to be moved to dest If a file is only in dest, I want it ignored IE left ...
0
votes
0answers
19 views

bashrc file read error in xterm

My bashrc files is read but is not interpreted correctly. qwul@qwul-ThinkPad-L440:~$ cat .bashrc #PS1='\[\e[1;32m\]\][\W]\$\[\[\e[0m\]\]\] ' alias la="ls -a" #alias ll="ls -l" ...
8
votes
3answers
926 views

What is the equivalent of bash's !$ and !! in the fish shell?

I've been using bash for a decade or so and have gotten used to being able to type !$ to repeat the last argument, e.g.: $ mkdir foo $ cd !$ cd foo (That last line is printed by the shell to tell ...
2
votes
1answer
35 views

How do I determine the PID of my python program if there is more then one python program running?

I have two python programs running on my system, say they are called program x and program y. I want to get the pid of program y, but not x for my bash script. When using pgrep python, I get the pid ...
0
votes
1answer
26 views

bash error when starting shell from tmux

When I open a new shell in tmux I get an error message. This error message does not show up when I start a new shell in GNOME terminal. What might tmux be running at startup that I need to check? ...
0
votes
1answer
18 views

Extract each digit of variable and store as new variable in bash

I have a variable that is a number ranging from 1 - infinity. Lets say the number is 40. I need to store 4 as a variable, and 0 as a variable. Since the number can grow beyond 2 digits, lets say the ...
1
vote
1answer
67 views

SSH Bash script for repeated commands on a network cluster

I have a network cluster of about 100 machines, a piece of software and a large list of different parameters for the software. I want to use the cluster to speed up the calculation, so each machine ...
8
votes
4answers
2k views

bash pipe construct to prepend something to the stdoutput of previous command

I want to use sendmail to send me stuff and want to do it in a oneliner. echo "mail content" | sendmail emailataddres.com Sends it without subject. The subject line must come before the Mail ...
1
vote
1answer
28 views

parsing condensed options to bash

I have something like this: while [[ $# > 0 ]] ; do key="$1" count=0 echo "$1" case "$key" in -r|--rotate) shift rotate $1 shift ...
0
votes
2answers
18 views

Trunc xml file using unix shell script

I need to select particular set of tags which contains a particular value inside the tag. For example, below is the source.XML file <main tag> <subTag1>1298</subTag1> ...
6
votes
6answers
8k views

Terminal *output* history?

I make extensive use of the functions to navigate through the command history in my terminal; I wonder if there is some way to navigate the command output history as well? (besides keeping a large ...
0
votes
0answers
52 views

bash script how to change date with hrs format and add missing days with copy of above line [migrated]

I have csv file with data: "smth","txt","33","01-06-2015 00:00" "smth","txt","33","02-06-2015 09:06" "smth","txt","34","03-06-2015 09:54" "smth","txt","34","04-06-2015 00:09" ...
4
votes
3answers
5k views

Move a range of numbered files?

I've got 291 numbered files (starting at 001 - title and ending at 291 - title) that need moved into separate directories. (001 to 021 to folder 1, 022 to 053 to folder 2, they aren't necessarily the ...
0
votes
0answers
32 views

Backup script to online backup - Pseudocode look over

I just want to pitch an idea here, before I start writing the code. I thought I build it in bash. I am not very proficient in writing scripts, but I had a few successes and this could be good training ...
0
votes
3answers
101 views

Multiline && combinator operator for command chaining in batch file

I see that this operator is used in windows (and might be Linux?) to chain/combine multiple commands in one line. Commands are executed one after another, as long as preceding complete successfully ...
0
votes
2answers
42 views

How to tell what are my startup files for sh or bash?

From this question I understand that depending on the operating system sh and bash behave differently. Doing env and alias I can tell that: Every time I open a OSX Terminal or run bash the variable ...
1
vote
1answer
26 views

How to use unlimited list of arguments to a command in bash shell?

I'm running up against the "argument list too long" problem using a command in the shell (bash in my case). Most suggestions for working around this suggest using find or some variation, presuming ...
1
vote
3answers
52 views

How to use grep or awk to save every line from text file as new file?

I am a scripting beginner. What i am trying to do. I have a text file that looks like this (example): hello hi there apple I am trying to make a script that saves every line as a separate new file ...
0
votes
1answer
22 views

OS maintenance scripts: bash or Python? [closed]

I'm creating more and more OS maintenance tasks across half a dozen computers I have. These are mainly OS X and Linux systems. The tasks are simple enough things like backups, permissions ...
0
votes
3answers
602 views

Virtualenv for bash

I really like virtualenv when working with python code and am wondering if there existed some tool which could emulate some of it when working in bash. What I want is some cleanly reverseble way of ...
12
votes
5answers
31k views

command not found when using sudo

There are a few question on the site that seem related to my problem but I could not find a solution in any of them. My operating system is Ubuntu 12.04. I have mvn installed in ...
0
votes
0answers
35 views

Changing the HOME for Cygwin

I'm trying to change the home directory for Cygwin on a computer at work. Our home directories mapped to a network share by default. This seems to cause some confusion for Cygwin, as it created a ...
4
votes
2answers
525 views

Bash autocomplete for different directories

I've played with bash autocomplete now for a while, but couldn't find a solution for my problem. I have a project directory with subfolders like this: projects/ruby/project1 projects/ruby/project2 ...
0
votes
1answer
23 views

Particular bash bc usage not storing result in variable

Unfortunately this result in a empty variable, and bc command print its result to terminal anyway while trying to attribute to aux aux=&(bc -l <<< "scale = 5; ...
1
vote
0answers
33 views

Shell Commands not working : REDHAT

I added some service to the startup script and then after reboot , i got this message- 24 package(s) needed for security, out of 52 available Run "sudo yum update" to apply all updates. -bash: id: ...
2
votes
1answer
45 views

Execute command after broken SSH connection

Is there a way to execute a command after an SSH connection is broken (blackout etc.)? When I normally log off I can just use .bash_logout but I don't know what to do when my connection breaks.
1
vote
2answers
32 views

Is there a way to make my .bash_profile load the contents of my .profile file?

I was using a .profile quite happily for two years on my Mac now running Yosemite. A recent brew install created a .bash_profile and whilst my .profile still exists, it is now no longer loaded. I ...
0
votes
1answer
23 views

Why does my vim colorscheme stay after I close vim?

I recently used vundle to install the solarized theme for vim on my Arch Linux machine. Whenever I open vim, the theme is applied, but it stays applied to my terminal window after I close it. I can ...
0
votes
1answer
32 views

Error while trying to execute cron script with space in path

I have a script with several rsync commands in it. The script file is placed in an NTFS partition with owner and group permissions set to root. I have no problems running the file manually from the ...
19
votes
4answers
21k views

I want to change DPI with ImageMagick without changing the actual byte-size of the image data

In GIMP there is a very simple way to do what I want. I only have the German dialog installed but I’ll try to translate it. I’m talking about going to Picture -> PrintingSize and then adjusting the ...
1
vote
1answer
60 views

Can't find the good Cygwin shell executable

I am working on Windows 7 and I need Cygwin for my project. I am trying to launch the Cygwin terminal from a Java programm and then write command lines but my problem is that I can't find the right ...
0
votes
1answer
45 views

Changed cygwin home location, now the terminal can't find my .minttyrc config file

I had to change the HOME location for Cygwin by setting it to pick up the directory I set in /etc/passwd (following the solution from here). It seems to not be a problem for the majority of my ...
1
vote
1answer
15 views

Using strace, how do I use it to get the network and serial calls

I have a python program that runs in the background, what I need to know for debugging purposing is that I need to see what calls it is send and receiving for serial, network and to stdout. I know ...