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

learn more… | top users | synonyms

0
votes
1answer
28 views

Sharing variables between applescript and bash script in same script

Is it possible, in a bash script, to have a variable, but also allow applescript (with osascript) to use that variable?
1
vote
0answers
34 views

Sourcing .bashrc does not enable use of nvm

I'm trying to set up a shell script to run in the context of a user account after the creation of a virtual machine using vagrant; I am a windows user so I've limited exposure to bash scripting. I'm ...
15
votes
4answers
13k views

Find files filtered by multiple extensions

What is the correct syntax for: find . -type f -name \*.\(shtml\|css\) This works, but is inelegant: find . -type f -name \*.shtml > f.txt && find . -type f -name \*.css >> f.txt ...
0
votes
1answer
41 views

Git Installation Returns Error 404 On RHEL

I am trying to install Git in my REHL but failed. I have also clean up metadata and everything else by running sudo yum clean metadata and sudo yum clean all but still, the error persists again and ...
0
votes
0answers
18 views

What is the alt+~ hotkey on the bash terminal?

I was switching between windows today (alt+`) and had my finger on shift as well it seems - this popped up in my terminal, avahi user mysql ...
0
votes
0answers
16 views

How to rerun a program if word `error` is detected on STDERR?

I am using a compiler that is pretty moody. Sometime it crashes for an unknown reason. Inside my Makefile I would like to rerun the build in case of an error. So far I wrote this: TRY=3 until [ ...
1
vote
2answers
30 views

understanding tilda,slash command in bash

I have confusion in the meaning of command ~/ if x is a directory, then what is the meaning of ~/x in bash. Please guide me
2
votes
0answers
22 views

Program options have sometime one or two dashes (-foo, --foo) [duplicate]

In gcc every command line arguments have one dash. In some other tools, options that are not a single character have a two dashes prefix. Why is there two standards, which one is the most common? ...
0
votes
1answer
41 views

SLURM allows jobs using more CPUs than requested to start

The problem I am facing with SLURM can be summarized as follows. Consider a bash script test.sh that requests 8 CPUs but actually starts a job using 10 CPUs: #!/bin/sh #SBATCH --ntasks=8 stress -c 10 ...
0
votes
1answer
16 views

ssh session stuck after some time of idleness

I'm using fedora 19 and bash 4.2.53(1)-release If I leave an ssh connection opened for some minutes and don't do anything with it, the terminal get stuck. Here's netstat's output: tcp 0 ...
2
votes
1answer
45 views

Function using watch on command with command line arguments

I want to run watch on a command which uses an optional command line argument, like this: function queue() { watch -n 10 'squeue -p ${1:-default} -o "%.8i" ' } but the command-line argument ...
0
votes
1answer
42 views

how write in script bash: su - user, command, password, without ask me password? [duplicate]

i will create file sh (bash script) #!/bin/bash su - username -c XXXXXXXX xxxxxx= command where i put my password?( but NOT ask me password in terminal..how?)
0
votes
3answers
102 views

Linux - Avoid cat: no such file or directory when file does not exist

I am checking via a bash script whether a process is running based on the PID stored in a file. I get the error shown above when the file does not exist as the command is trying to access the file and ...
4
votes
4answers
12k views

No bashrc file in my home directory

Here is what I noted down from my lecture: Find file .bashrc in your home directory do vi .bashrc When you put an application folder somewhere, make sure that its address is in the path variable. ...
1
vote
4answers
3k views

How do you pass a file or folder containing whitespace as an argument to a command-line program in a GNU/Linux or Cygwin environment?

There are occasions when you are working with files and folders that contain spaces in them. The problem is any time you try and pipe files / folders containing whitespace to another command-line ...
-1
votes
2answers
31 views

Only show part of logfile in bash script

OpenVPN log looks like this: OpenVPN CLIENT LIST Updated,Sat Jun 20 04:20:07 2015 Common Name,Real Address,Bytes Received,Bytes Sent,Connected Since [ A .... ] ROUTING TABLE Virtual Address,Common ...
0
votes
1answer
42 views

Accidental recursive cp -R, now can't delete file using either Trash or rm

After a mistype in a path when using cp, I seem to have accidentally copied the folder in to itself recursively, and now I can't delete that folder using rm -rf, or the Trash in Mac OS X Finder. The ...
4
votes
1answer
3k views

Bash Shell Scripting - How to iterate through directories, and copy and rename files?

I have a directory setup as follows: /hosted/partner1/logo.png /hosted/partner2/logo.png /hosted/partner3/logo.png /hosted/partner4/logo.png /hosted/partner5/logo.png ..etc. I want to write a ...
18
votes
5answers
151k views

How can I resolve the error “cannot execute binary file”?

When I login using SSH, all I can see is this... -bash: /usr/bin/id: cannot execute binary file -bash: [: : integer expression expected I couldn't do anything in here. Commands such as halt, ...
8
votes
3answers
1k views

Is there a ”reverse incremental search” functionality in Fish similar to Bash’s CTRL+R?

I’m really impressed with Fish’s autocomplete functionality. However there is one feature in Bash that I’m unable to find in Fish. When you press ctrl+R in bash and begin to type out a term, a search ...
0
votes
1answer
31 views

How to autocomplete filenames with “wordwise” camelcase matching in bash?

While programming using QtCreator, I got used to its camelcase-aware completion, e.g. typing MC<ctrl-space> would offer MyClass as a completion option. Now I am basically annoyed about that ...
0
votes
2answers
22 views

Reference shortcut

I am new to OSX/linux. I have all my development stuff in the following location: ~/Dropbox/Dev/CompanyA Is there anyway I can create a link to that folder by just referencing ~/dev or something? I ...
3
votes
4answers
19k views

Bash in Mac OSX terminal: “command not found”. Why?

When I want to enter a command (for example say) it returns a message like this: bash: say: command not found. It appears every time I write a command. What do I have to do?
4
votes
1answer
51 views

What does chmod 7760 <directory> do in CentOS 7 bash?

I typed the command chmod 7760 by accident. I meant to type chmod 770 and now I'm curious what the first command did exactly. After typing chmod 7760 , I typed ls -Al and the directory name was ...
0
votes
1answer
32 views

need to get average idle time using mpstat

I want to get average idle time of the server using mpstat. The problem I am having is %idle is not in same columns in all the versions of linux. example 1: [root@testserver ~]# mpstat 1 2 Linux ...
1
vote
2answers
31 views

Can xargs evaluate $HOME?

When I type in echo $HOME/Downloads | xargs cd It correctly changes directory to $HOME/Downloads. Maybe that is because echo evaluates $HOME before piping to xargs. However if I type echo ...
0
votes
1answer
38 views

Piping a line of the file read with while read loop

I am trying to read each line of the file and then assign some parts of it to variables. A line itself is read as a variable so I need to process a variable input say for cat which seems to be ...
0
votes
0answers
35 views

Why “ls” command highlights some folders?

Why LS highlights folder PyFac ? How disable this highlighting? IMG My .profile: if [ -f $(brew --prefix)/etc/bash_completion ]; then . $(brew --prefix)/etc/bash_completion fi export CLICOLOR=1 ...
0
votes
2answers
28 views

How to get Syslog Referer URL

I have two urls one.example.com and two.example.com, is there a way in the syslog conf of capturing which URL was used to hit the server? I need to modify a database filed based on this information. ...
2
votes
1answer
83 views

bash script to compare dates within a diven dir (incl. subdirs)

I would like to write a bash script (or just use a command in the CLI) to find all the instances within a given directory and its subdirectories for a given time period copy those files into a ...
1
vote
0answers
29 views

executing script on remote host by ssh

I wrote a script test.sh (its function is the same as "hostname" command) as below, #!/bin/bash printf "`uname -a | awk '{print $2;}'` " I can get my hostname with source /home/arton/test.sh or ...
3
votes
2answers
55 views

How can I restructure this line of bash code so that I can comment on each instruction?

I have a line of bash: SAMPLES=$(for f in `find $IN -iname *fastq.gz `; do basename $f | cut -c 1-4; done | sort | uniq) which I am attempting to break up into multiple line for the purpose of ...
4
votes
4answers
12k views

How can I launch multiple screen sessions from a single bash script?

I've written a script (that doesn't work) that looks something like this: #!/bin/sh screen -dmS "somename" somecommand for i in {0..5}; do screen -dmS "name$i" anothercommand $i done For some ...
1
vote
0answers
39 views

Issue installing Java EE 7 SDK update 1

I've installed Java (jdk 1.8) and set JAVA_HOME, now I'm trying to install Java EE 7 SDK which I downloaded it from here. The Oracle download page shows Universal Zip Installer type file, downloaded ...
1
vote
2answers
305 views

Efficiently stripe incoming one-word lines onto columns?

Consider a stream of one-word lines such as the stdout of $ echo foo bar baz quux xyxxy thud | tr ' ' '\n' foo bar baz quux xyxxy thud I say "one-word" to indicate there is no whitespace other than ...
1
vote
1answer
27 views

Aliasing piping operations in bash

I frequently will do something like grep -R foo . at the root of a project. It’s helpful but the results get diluted by the inclusion of binary. temp, and test files that I don’t care about. So I end ...
1
vote
1answer
49 views

libtool installed but not found in /usr/bin

I have to compile a program (not made by myself) and in his autogen.sh there is a script command that search libtool LIBTOOL=$(which libtool) but the command don't find the command. I see the path ...
1
vote
2answers
39 views

Completion when pasting Bash command beginning with tabs

I'm writing a Dockerfile which I'm formatting using tabs (which I usually use everywhere). But I've copied a multi-line command where the second line begins with two tab characters, i.e.: apt-get -y ...
1
vote
1answer
20 views

Monitor SSH login's via slack but hangs on SCP

I'm playing around with some slack integration so that every SSH attempt gets sent to a slack channel The script below works perfectly for SSH attempts but the issue is that when I preform a SCP to ...
2
votes
1answer
23 views

Appending a unique identifier to bash commands

I'm running a command, and I'd like to be able to use pkill -f to kill that specific command instance later. There's no reasonable way for me to get the PID. So, my idea was instead to append a ...
0
votes
1answer
34 views

How to delete folder and files in the destination that are missing in the source (before copying)?

I sometimes have the problem that rsync tries to transfer a new file from the source to the destination (both have the same space) when there's already not enough space left, which causes this error ...
72
votes
17answers
21k views

Add directory to $PATH if it's not already there

Has anybody written a bash function to add a directory to $PATH only if it's not already there? I typically add to PATH using something like: export PATH=/usr/local/mysql/bin:$PATH If I construct ...
0
votes
2answers
48 views

How can I find all files that contain a string and then replace these files with another?

I want to replace all files (foo.php as example) that contain certain string 'bar' with a backup foo.php file, which is located in ./backup/foo.php. How can I do that? I know if I grep -lrI foo . all ...
3
votes
1answer
37 views

In bash, declare an alias that depends on current variable content

I would like to declare an alias (in my .bash_profile) that will use the content (value) of a variable when the alias is used, not when it is defined. E.g., alias goSomeWhere="cd $BASE/somewhere" ...
0
votes
1answer
53 views

Bash Script to generate <name> and pass this as command line argument to programm

I have an python script which gets 1 command line argument python arg Now I want a bash-script which: calls python arg & with the argument arg=000 make this x-times so therefore: python ...
0
votes
1answer
42 views

In bash script, how to generate a random string

I need to generate many random alphanumeric strings, which also use capital letters. It needs to start with 3 characters (e.g. Dk6) and then, with a while loop, go up to about 9 characters (e.g. ...
146
votes
13answers
123k views

How do I detach a process from Terminal, entirely?

I use Tilda (drop-down terminal) on Ubuntu as my "command central" - pretty much the way others might use GNOME Do, Quicksilver or Launchy. However, I'm struggling with how to completely detach a ...
1
vote
2answers
215 views

/dev/dsp missing in debian and cannot hear festival utterance

Tried to make an utterance in festival and it seems /dev/dsp/ is missing in the debian. How to add this? festival> (SayText "Hello") Linux: can't open /dev/dsp #<Utterance 0xb669c708>
0
votes
2answers
41 views

OS X Bash 4 terminal exits

I have the latest OS X running the standard terminal app, with bash 4.0 via homebrew However, if I run a script that contains an exit command, it's expected it would exit the script. Instead the ...
1
vote
4answers
155 views

When copying directories with sudo it copies just the first level of its hierarchy

This question was also asked here. When I copy some directory (dir) recursively with sudo in bash it copies just the first level of the dir hierarchy, but when used without sudo it copies the dir ...