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

learn more… | top users | synonyms

1
vote
2answers
27 views

Is there a way to have sh/bash/zsh “case” use a variable for a test value?

I'd like to have something like the following: #!/bin/sh # ... other stuff ... # some relatively static possibilities (srsp): srsp='this|or|that|the|other' # more other stuff case $something in ...
0
votes
1answer
46 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 ...
1
vote
1answer
98 views

Run command for every line of a file in bash, passing lines as standard input

How do I pass some input to a command line by line (ie. invoke the command for every line)? xargs does not work because it passes the lines as arguments, not as standard input. The specific case ...
1
vote
0answers
60 views

bash- command does not work with php shell_exec

I want to execute following command on my Ubuntu server using php: android create project --target 8 --name $fname --path ./$fname --activity MainActivity --package $fpack 2>&1 The above ...
1
vote
3answers
36 views

How to move in a big jump on the bash shell?

Ctrl + A and Ctrl + E bring you to the beginning and end of the command line. How do you jump to the middle? or at least 20 chars or so? If any of you use bash a lot and type quickly, you end up ...
0
votes
0answers
17 views

Starting a chroot and drop into nonprivileged user home

I need to (temporarily) jail a non-privileged user. I tried something like: sudo chroot --userspec=mcon:users /wherever/chroottarget /bin/bash -i This almost works, but it doesn't set env vars ...
3
votes
1answer
42 views

how to control users login on Linux machine according to configuration file

I use the PAM to authenticate users login info from - http://linux.die.net/man/8/pam_listfile in my Linux red-hat machine I have 5 diff users user1 user2 user3 user4 user5 I want to enable ssh ...
1
vote
3answers
49 views

sudo command won't run from script

Linux Mint. Ok, this is going to be seriously basic but for some reason, I am mis-understanding how this works. If I type the following commands, everything works fine: cd ...
1
vote
1answer
34 views

Alias one program in a different order than $PATH

I alias pandoc='~/.cabal/bin/pandoc' because I don't want to change my $PATH order just for this one program. In general, programs I installed in /opt/, ~/.cabal/, and so on should precede defaults ...
0
votes
2answers
102 views

How to run a script after startup on Ubuntu 14.04?

I have scoured the web and tried numerous solutions. Nothing has worked for me so far, hence this question. I have a rails application that I run with mongrel_rails start -e production -p 80. That ...
2
votes
0answers
44 views

What are the benefits of keeping Caps Lock on after swapping with CTRL? [closed]

I have swapped CTRL and Caps Lock (as it is easier for emacs/bash to have homerow access to the CTRL key). Most places I have read don't mention whether they just turn off Caps Lock (don't remap to ...
0
votes
0answers
21 views

How to pipe arguments into stdin?

I am trying to generate a private key using keytool command, but it asks me for many details like my key passphrase, my name and my organization details. I want to pass all the inputs in one command. ...
0
votes
5answers
55 views

No such file or directory after typing $PATH in terminal

when I write in terminal echo $PATH my output is :/home/bo/bin:/usr/local/bin:/usr/sbin:/usr/local/sbin:/usr/bin:/sbin:/bin but when I write just : $PATH this output I do not understand ...
1
vote
1answer
41 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 ...
0
votes
1answer
32 views

How to stream audio and capture at the same time

I would like to save the mp3 that is being stream to the local file for archival purposes. I'm using the following line in my bash script to stream audio from a USB audio device to my icecast ...
2
votes
2answers
35 views

/etc/profile not being sourced at login

I'm having a bit of an issue: Neither of my /etc/profile or /etc/environment are getting sourced at login! i.e: After boot, the global variables I've got set in /etc/profile (and /etc/profile.d/*.sh ...
2
votes
1answer
149 views

I have to manually start bash

I'm somewhat a Linux noob, so I'm sorry if this is a very basic question. I tried to look on superuser for other answers, but i'm not exactly sure what i'm looking for. So, here's my problem. When I ...
0
votes
2answers
73 views

bash sed/awk: replace string from a file searching in another file

i have a question about search and replacement on Debian. I have two files. One with: a:b c:d e:f and the other with: e c a` In the second file I want to replace a with b, c with d, e with f. ...
2
votes
0answers
51 views

How to curl or wget live tennis scores from a Google search page [closed]

Google has some nice live tennis scores displayed on the search page. If I search for "Halep", for example, I get the tournament she's currently playing, together with all the result and live score. ...
0
votes
0answers
46 views

Crossfading Video AND Audio with ffmpeg

This Super User answer crossfade between 2 videos using ffmpeg has got me so far, but now that I have tried many solutions and seen every SO link out there, it's time to ask you all for help. I am ...
0
votes
1answer
27 views

Escape string input to sed

I'm having some problems with replacing a string in a file using sed with a string that contains newlines. The following will fail completely. I assume I've got to escape the replace_with string, but ...
0
votes
1answer
31 views

How to cp multiple file extensions?

How do I cp multiple file extensions, like png, jpg and tif files? I tried: $cp ./*.(jpg|png|tif) ../output/ >bash: syntax error near unexpected token `(` $cp ./01_reliefs/*.\(jpg\|png\|tif\) ...
0
votes
1answer
11 views

how to keep bash from waiting for spawned windows gui program to close

New to bash. And new to bash on windows and git. When I run gitk in the git-bash shell created by msysgit, bash will effectively hang waiting for the spawned gitk to close... Whereas cmd launches ...
2
votes
3answers
176 views

What is the difference between terminal and bash? [duplicate]

When I open Terminal Window in Mac OS X, I can type bash and hit enter and I will see: Last login: Fri Feb 20 14:30:56 on ttys000 Korays-MacBook-Pro:~ koraytugay$ bash bash-3.2$ I can for example ...
1
vote
2answers
43 views

Wrong results when comparing two numbers with bc (bash)

I’ve encountered an error, probably a bug in bc. I encountered it when trying to compare two numbers on a script in bash. It turns out that when I do: echo "1.1E-2<1.1E-1" | bc -l It returns 1 ...
1
vote
0answers
18 views

bash Segfault by infinite recursion

I just noticed that the bash I'm using (4.2.25(1)) isn't protected against infinite function recursion. In such a case a Segfault happens (and the bash process terminates). To check this on your ...
0
votes
1answer
34 views

Is there any difference between -exec cmd {} and xargs -I?

Normally, xargs bundles everything together, but when used with the -I flag it seems to put evaluate everything as a single line. Does this mean it loses its speed advantage? Also if the -exec cmd {} ...
1
vote
1answer
40 views

Can't run /bin/bash… sometimes?

I’m on a Google Compute Engine which is running Debian Wheezy 7.4. I’ve been noticing strange things recently. For example, I can do sudo bash. But then, from root, I can’t do sudo -u anotherUser ...
0
votes
1answer
45 views

How to configure linux to display webpage at localhost 127.0.0.1 that allows javascript-issued terminal commands?

Sorry if I am confusing things (don't know much about this topic). Basically, I want to access my raspberry pi wirelessly from my phone as long as I am within a few meters of it, and in this situation ...
0
votes
4answers
51 views

Please explain the man page of command mv

I understand if I mv foo.file boo.file, I just rename foo.file to boo.file, and if I mv dir1/foo.file dir2/boo.file, I delete dir1/foo.file and make a copy of that to dir2 and rename it as boo.file. ...
1
vote
1answer
33 views

Removing illegal characters with Automator

I've been trying to write a Mac Automator service to remove illegal characters from filenames. I have it working, but the solution is a little inelegant and I was wondering if anyone would have a ...
0
votes
0answers
24 views

How can I automatically run two commands in different screen windows with an argument?

My process is ctrl+a 0 command $1 ctrl+a 1 /join#$1 I'd like to shorten it down to one command.
-1
votes
1answer
21 views

Find specific file with a for loop

I have a list of files in multiple directories. I would like to work on specific files but the naming is a little tricky. file_986.aln file_99.aa.aln file_99.aln file_991.aa.aln file_991.aln I ...
1
vote
0answers
15 views

Grep from Log & Calculate then alert

I have a log file, which has the below lines in it. I need a bash script, which takes the values in Bold (4092.1M / 20.1G) & do the math & then alert from Zabbix [Eden: ...
0
votes
1answer
43 views

bash: adding a common string to files found with wildcards

I'm wondering if there is a way to rename a wide range of files that are found using wildcard patterns. For example, say I want to scp all files that match a certain pattern, but append a string to ...
0
votes
1answer
95 views

Require bash script to be run with sudo (not as root user)?

I want to require a bash script to be run as the current user with sudo, but prevent it from being run if it was executed as the root user directly. This is because I'm doing some setup actions for ...
1
vote
1answer
32 views

BASH - run commands before and after loop

I'm having a bit of trouble with a shell script. It's something so stupid I'm almost ashamed to ask, but I can't figure it out. This is the script: #!/bin/bash MAGAZINE=" 192.168.49.3 ...
0
votes
0answers
8 views

Bash/Cygwin synchronize two directories

I have small problem with synchronization of two git repositories. In first directory for example localRepo is only two subdirectories: localRepo/ dirA/ dirA1/ ...
3
votes
2answers
63 views

Loop in a script until file exists

I'm trying to have a script find a file in /tmp called sleep.txt but instead it keeps looping Here's what I have: #!/bin/sh set -x until [ $(ls -la | grep -w "sleep.txt" | wc -l) != 0 ]; do ...
0
votes
1answer
48 views

Unix Script: Wait until a file exists

I need a script that will wait for a (examplefile.txt) to appear in the /tmp directory and once it's found to stop the program, otherwise to sleep the file until it's located So far I have: if [ ! ...
0
votes
1answer
33 views

Piping grep causes error $'\302\240grep': command not found on linux

Sometimes when I'm catting & grepping a file, I see this error come up: $ cat something.txt | grep "some text" -bash: $'\302\240grep': command not found When I re-type the command, it works as ...
0
votes
1answer
40 views

Programs for contolling the execution of bash scripts [closed]

Can anyone recommend a GUI based program to control the execution of bash scripts according to time/interval? I'm already familiar with both cron and at and looking for recommended alternatives. A ...
2
votes
1answer
48 views

strange if statement behavior on linux

I am writing a shell script and have come across some weird if behavior. My question is simple, why does [[ "╝" = [█] ]] evaluate to true? Is it because they are both uncommon ascii characters? On ...
0
votes
0answers
20 views

`newgrp` breaks source-ability of shell script

This is my minicom.sh, which I can source successfully with source minicom.sh: minicom --device /dev/ttyUSB0 --baudrate 115200 --color=on However, when I change the content of minicom.sh to this, ...
1
vote
1answer
14 views

Inconsistencies with which command

I'm using the n tool to update my current version of node, but something strange is happening. I ran sudo n latest which in theory fetches the latest version of Node (v0.12.0 and installs it ...
2
votes
1answer
38 views

How to start terminal in which bash is running with adjusted environment variables?

I'm using Xubuntu with XFCE. I would like to write a bash script which opens a new tab in the xfce4-terminal. In this tab, the bash should be running with an altered PATH environment variable. ...
1
vote
1answer
39 views

Is there a way to enable minicom linewrap by default

I use minicom when working on router terminals... by default, I use these settings in my ~/.minirc.dfl: pu port /dev/ttyUSB0 pu baudrate 9600 pu bits 8 pu parity ...
0
votes
0answers
30 views

Proper way to execute a script before running upstart based service?

I run the deluge torrent client within a virtual machine that mounts an NFS share from the filer that runs bare metal. Occasionally deluge starts before NFS has been mounted, and it starts downloading ...
0
votes
1answer
19 views

ssh | how to handle errors for multiple commands

Hi I am aware that we can check the status of previous command by $? following scenario is not working for me ssh $USER@$HOST bash -c "' echo "Preparing list of files to be transferred...." rsync ...
0
votes
1answer
52 views

Bash Scrolling Output Cygwin

My apologies if this has been asked before but I did my best to find it beforehand. I have a bash script like so: #!/bin/sh <Appropriate variables here> lftp -c "open -p $port -u $login,$pass ...