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

learn more… | top users | synonyms

3
votes
0answers
240 views

Bash auto-completion of variables adds additional white space at the end

when I perform an auto-completion of a bash variable an additional white space is added at the end. $FO[TAB] -> $FOO" " I added the quotes in order to denote the white space. The problem is ...
0
votes
1answer
31 views

conemu multiple bash cygwin ssh

I just want to know how to have multiple tabs logged in to a server via ssh to for example ssh user1@1.1.1.1 for a tab named server1 (to some particular folder location) and ssh user2@2.2.2.2 for a ...
0
votes
1answer
101 views

BASH: Bracketing Parameters

Simply, whats the fundamental difference between $param and ${param} ?
4
votes
5answers
2k views

xargs command works on ubuntu, but not mac

I have the following line of code that I use to update my personal date variable in my projects to today's current date. This line works in Ubuntu's terminal, but the Mac terminal seems to be far ...
1
vote
1answer
16 views

Get user logged into a given tty

I'm writing a bash script that disconnects idle sessions but writes to the tty a few seconds before terminating it to make sure it really is not being used. The format for write is write user [tty]. ...
0
votes
0answers
27 views

Shell command shortcut using input filename as output filename

Hi could someone help me with a little command shortcut please? Im trying to run an ffmpeg command and was wondering if there was a shorter way to type it, Ive been reading up on parameter expansion ...
0
votes
1answer
31 views

What does `-n` option in sed do?

This is the man page entry for -n: -n suppress automatic printing of pattern space I notice that when not using -n for certain operations, each line is printed to stdout (and the requested ...
1
vote
1answer
23 views

Grep fails to find sequence after assign to variable

I run: awk -F ',' '{print $2}' data.dat | sort | uniq | tr '\n' ',' | grep "*)>nS4XkrlH @XUL" and the sequence is located in results. Then I run b=`awk -F ',' '{print $2}' data.dat | sort | ...
2
votes
2answers
199 views

Why does the 'vi' command open 'vim' editor?

I am using Ubuntu 12.04. Not that I am complaining as I like my vim and prefer its many features. However, I’m curious as to why it does it. It is not aliased in .bashrc or .bash_profile. I am not ...
0
votes
3answers
55 views

Bash: executing concatenated variables

I have a Linux bash script, to the effect of: COMMAND_TO_EXECUTE="foo "$1" --option1 --option2 "$2 exec $COMMAND_TO_EXECUTE Problem: the script fails Debugging clue, If I echo ...
5
votes
2answers
526 views

Equivalent of bash's Ctrl-r in PowerShell

does anybody knows of a way to have the backward command search feature of bash [Ctrl-r] (and [Ctrl-o]) that are so useful, in windows powershell ? C-r is a more powerful arrow up history ...
0
votes
2answers
953 views

set global variable AND use stdout from bash function

Here's the code: #! /bin/bash function foo() { G1=123 echo "ReturnVal" } RV="$(foo)" echo "RV=$RV, G1=$G1" # RV=ReturnVal, G1= foo >/dev/null echo "G1=$G1" # G1=123 I want to execute ...
5
votes
2answers
7k views

Why do I Get [[: not found When Running a Script?

I'm trying to write a script that has to check if a file exists. In the console I write if [[ -a /path/to/file.txt ]]; then echo "not mod"; else echo "mod"; fi and I get not mod but when I write ...
0
votes
0answers
41 views

RVM wants me to edit PATH in .bash_profile - I fear it is a mess

I am trying to get an Omega sub-theme running on my local machine (OSX 10.10) with Acquia Desktop Dev. Trying to run isolated ruby in sub-theme directory. When I use rvm list I get: Warning! PATH is ...
2
votes
3answers
1k views

How do I su to user login shell directly

I do the following many times a day I login to a server via ssh as user1, I then do su - to become root, then I do su --login user2 to become user2 Is there a way to tell su to go to user2 ...
0
votes
1answer
17 views

Launch a bash sub-shell and expect a command

From a shell script, how can I launch a bash sub-shell for the user & wait for the user to type exit at the bash sub-shell prompt? I tried bash -c expect -c 'expect "exit" {send "Exiting\n"}'; ...
0
votes
1answer
22 views

Is it possible to check for blips in internet using SSH tunnels?

So basically at work we're losing internet connectivity for just a few seconds at a time, which is enough to kill our SSH tunnels, kill our VoIP calls, etc. I have a cronjob set up with my own script ...
3
votes
4answers
219 views

*NIX - does exporting a variable only last while machine is on?

I know that I can set a variable, 'export' the variables and put an alias statement in my .bash_rc file. So: When I just set a variable it just lasts for that session and is not visible to other ...
2
votes
2answers
207 views

tilde expansion fails when running “cd -” in bash

Recently I find I can't use cd - to go back to last directory sometimes. It gives the error of -bash: cd: ~/whatever_dir: No such file or directory. A closer look shows that the error only happens if ...
1
vote
2answers
42 views

batch rename multiple mp3's stripping leading digits

Hi could anyone help me? Im trying to strip leading digits from multiple mp3 files so "01 some_file.mp3" would become "some_file.mp3" if any one could show me how to doit with zmv that would be great
0
votes
0answers
11 views

Defining git commands on windows

I have a script that I use to add some functionality to git. For this particular case I cannot do it with an alias. The name of the script is git-cim. In linux if I place this script in my path and ...
4
votes
1answer
46 views

Tar using progress bar and handling multi-volumes

I'm trying to create a tar of a large LVM volume onto multiple external drives. That part is solved. Now, because it is a LONG process, I'd like a progress bar. From the excellent articles here, ...
1
vote
3answers
37 views

Bash script to find all folders containing a specific file and copy a new file to those folders

I'm trying to write a script that will loop through all subfolders of a directory to search for a specific file and then copy a new file to those folders that contain that file. This is what I have ...
1
vote
2answers
17 views

Is there a way to pass arguments via pipe on bash?

Is there any way to pass arguments via pipe on bash? something like: echo value1 value2 | mkdir -p ./$1/$2 The line above would create the directories ./value1/value2 If this is not possible I ...
1
vote
2answers
12 views

Add directory only once to any variable

I started this question by looking at Add directory to $PATH if it's not already there. In my case, I wanted to do the same to LD_LIBRARY_PATH also. How to do that without writing a script for ...
1
vote
2answers
137 views

Strange bash error: “error importing function definition for `BASH_FUNC_module'”

Sample script: #!/usr/bin/env bash echo "abc" Output from Bash version 4.1.2(1)-release: $ ./a.bash bash: BASH_FUNC_module(): line 0: syntax error near unexpected token `)' bash: ...
0
votes
0answers
21 views

Is it possible to modify .bash_logout?

I am trying to modify .bash_logout to append the shell history to a txt file. I am also trying to figure to make some restrictions on that file. I have tried a bunch of commands while searching about ...
0
votes
1answer
44 views

Jenkins SSH Windows node bash error

I have Jenkins server for continuous integration and I want to add another node. Node is Win 7 station which runs Bitvise SSH server. On that Win 7 station is installed Cygwin 32 AND 64 bit (for ...
3
votes
3answers
2k views

Using the watch command with an argument that contains quotes

I'm trying to get watch to work correct with commands that contain quotes, and the watch man page isn't very detailed about how quotes work. To give a concrete example, how can I run the following ...
0
votes
0answers
12 views

ddclient updating to public IP instead of private IP

This is the antithesis to question 389125 I have private services (apache, ssh, synergys for example) accessible on a desktop on the local network. This is not with centralised login (ldap/AD for ...
59
votes
4answers
5k views

Why would you `cat /dev/null > /var/log/messages`?

On this bash scripting example page the author presents this script: # Cleanup # Run as root, of course. cd /var/log cat /dev/null > messages cat /dev/null > wtmp echo "Log files cleaned up." ...
0
votes
0answers
16 views

file RELATIVE_PATH must be passed a full path to the file

Everytime I want to build smth using: cmake -DCMAKE_INSTALL_PREFIX" I'm getting errors like this: CMake Error at /usr/share/cmake-2.8/Modules/CMakePackageConfigHelpers.cmake:177 (file): ...
0
votes
0answers
12 views

In-browser bash

I'm thinking over possible improvement of bash console. As for me, I'm not very happy with terminal shortcuts, which conflict with OS hotkeys. These days I work much with IPython, which has ability ...
1
vote
2answers
31 views

Having trouble replacing a specific hyphen in directories that follow a specific format in Bash

I have a list of directories using the format: 2014-12-03 13-03 2014-09-03 12-07 etc. I need to change them to: 2014-12-03 13:03 2014-09-03 12:07 … I’m trying to do this with for d in *\ ...
3
votes
2answers
4k views

BASH - merge directories when using mv

I just started using BASH, so I can move all contents of a directory to another. But the issue is, I was expecting it to merge the directories. I am using cron job to run this script. #!/bin/bash ...
0
votes
1answer
13 views

Move spam emails from directory - bash script

I am trying to write bash script wich can cleanup my whoole server from spam emails that already are present in my client's folders. I would need this script to do, Check recursively directory ...
0
votes
1answer
17 views

Bash: immediately disown job after it is started (Bash inbuilt equivalent of Z Shell's &!)

Is there a Bash equivalent of Z Shell's &! (or &|), i.e., immediately disown a job after it is started? I looked in Bash Reference Manual and searched in Google but can't seem to find anything ...
1
vote
2answers
93 views

Newlines while saving variable to file - bash

I have mulitiple ip adresses in a variable. ActiveIPs= 192.168.0.1 192.168.0.2 192.168.0.3 I want to save them to a file like this 192.168.0.1 192.168.0.2 192.168.0.3 how do i do this?
0
votes
1answer
30 views

OSX bash command line countdown timer

I found here on superuser the following nice countdown script that I could include in my .bash_profile: function countdown(){ date1=$((`date +%s` + $1)); while [ "$date1" -ne `date +%s` ...
0
votes
2answers
730 views

Usefull aliases in “.bash_profile”? [closed]

E.g.: echo 'alias myip="curl -s "http://checkip.dyndns.org/" | grep -o "[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*" | head -1"' >> /home/USER/.bash_profile when I type "myip" then I will get my public ...
0
votes
0answers
12 views

How to check a range of zipped files

I am looking for any ideas how to check for particular entry in given range of time in logs. If I am checking logs just from one day, I can do the following: more /var/logs/log.08.12.log | grep ...
2
votes
3answers
384 views

Bash script to print files that have a certain line length

I'm new to this… I need a script that receives a directory as a parameter and prints the names of files that have between 15 and 50 lines, but I don't know how use the wc output in an if-sentence: ...
1
vote
1answer
47 views

space at the end of variable is killed on output

I'm on Ubuntu 12.04 with bash 4.2.25(1)-release. If I use #!/bin/bash echo -n 'test ' > text; echo 'test2' >> text; everything works fine and the output of text is test test2. But if I use ...
1
vote
1answer
166 views

Run output of another command, with variable substitution

In bash, I often run awk programs with many preset variables. Most of the times I use the same variable names in both bash and awk, so I call awk like the following: awk -v var1="$var1" -v ...
0
votes
1answer
354 views

How do I use variables in bash to output to a file and to a mail body with sendmail

I've been working on this little script and it's nearly at a point that I can start using it. The idea is to automate WordPress installs via Plesk. I've got Plesk setup with a cronjob to download ...
5
votes
1answer
4k views

ssh config under cygwin

I have Cygwin installed on Windows 7. I made default install. I would like to use ssh config file (~/.ssh/config) to set host and options for connecting. Normal ssh command is not able to find the ...
46
votes
3answers
49k views

How to find the executable files under a certain directory in linux?

How to find the executable files under a certain directory in linux?
0
votes
2answers
29 views

confused about variables in bash

I know that variables in bash have no type, but am confused about the value they are assigned. The following simple script works fine in bash #!/bin/bash tail -n +2 /cygdrive/c/workdir\ \(newco\,\ ...
0
votes
2answers
32 views

Copy only *.h files with subfolders structure bash

I need to write a script to copy only *.h files with saving the folder structure: now it looks like this: cd "${SRCROOT}" echo 'Copying Cocos Headers into Framework..' cd .. for H in `find ...
1
vote
4answers
93 views

How do I test whether a variable has multiple non-blank lines in bash?

Say I have two variables in bash: MULTILINE="I have more than one line" SINGLE_LINE="I only have one line " I want to detect when a variable actually contains more than one line of text, ...