Questions about bash only, as opposed to other Bourne/POSIX shells. For all Bourne/POSIX-style shells, use the /shell tag instead.

learn more… | top users | synonyms

2
votes
4answers
192 views

Creating symbolic link recursively

I essentially want to run this command... ln -s /opt/gitlab/embedded/service/gitlab-shell/hooks/ /var/opt/gitlab/git-data/repositories/web/*/hooks This would create a symbolic link in all folders ...
24
votes
3answers
1k views

How can I see the exact command line being executed inside some bash instance?

I have a long running bash instance (inside a screen session) that is executing a complex set of commands inside a loop (with each loop doing pipes, redirects, etc). The long command line was ...
0
votes
1answer
47 views

generate password that is random length between 8 - 16 ( i have the generator but its not dynamic) [duplicate]

This is my password generator and it generates 8 characters and shuffles them. But i need to make it dynamic length. How would i go about doing that. So the output would be different length between 8 ...
1
vote
1answer
2k views

shellshock solution for nexenta/solaris

I'm trying to solve the shellshock issue on my system: SunOS localhost 5.11 NexentaOS_134f i86pc i386 i86pc Solaris # bash --version GNU bash, version 3.2.48(1)-release (i386-pc-solaris2.11) ...
1
vote
3answers
79 views

auto creation of bash profiles?

Following the instructions at this nice walkthrough here. I have successfully configured my CentOS 6.5 Server to authenticate with my domain. Additionally, it only allows domain users of the group ...
2
votes
2answers
3k views

grep output of expect script

I'm trying to run some expect language, and grep/parse the output all in one script. I want to grep the output of and look for "error" (I should note that standard linux commands like awk, sed, grep, ...
1
vote
1answer
57 views

Replace pattern in file with pattern in second file

I want to replace part of a file's data, with data from another file. Suppose file1 has data as is written below and file2 has some data I want to store and replace file1 data from file2 from ...
0
votes
0answers
35 views

patch bash at sunos5.7

Refer:shellshock solution for nexenta/solaris post for shellshock solution may I confirm the command is method1: /usr/local/bin/curl \ https://ftp.gnu.org/pub/gnu/bash/bash-3.2-patchs/bash32-001 ...
4
votes
2answers
292 views

What are the shell's control and redirection operators?

I often see tutorials online that connect various commands with different symbols. For example: command1 | command2 command1 & command2 command1 || command2 command1 && command2 ...
110
votes
15answers
49k views

How to do integer & float calculations, in bash or other languages/frameworks?

Using echo "20+5" literally produces the text "20+5" What command can I use to get the numeric sum, e.g. 25 in this case. Also, what's the easiest way to do it just using bash for floating point, ...
1
vote
1answer
30 views

Custom tab-completion in bash's `read`

Is there a way to "import" a list of words into bash's read builtin to have custom tab-completion? I've been writing a wrapper script for suckless' minimalist irc client "ii", and I don't have a way ...
4
votes
2answers
167 views

How to escape single quotes correctly creating an alias

I've been given this one-liner to know how much memory my processes consume. $ ps -u $USER -o pid,rss,command | \ awk '{print $0}{sum+=$2} END {print "Total", sum/1024, "MB"}' Now I'd like to ...
2
votes
3answers
2k views

How can I keep *all* environment vars for a specific command in sudo?

I have a script that sets several environment variables and then finally calls another script using sudo. The script run with sudo must be able to pick up those variables, and I'm not always going to ...
19
votes
3answers
6k views

Precedence of the shell logical operators &&, ||

I am trying to understand how the logical operator precedence works in bash. For example, I would have expected, that the following command does not echo anything. true || echo aaa && echo ...
0
votes
2answers
42 views

Get the file list in an HTML directory listing

I can get all files on the bash patches site by downloading them in a sequence: SEQ=$(seq -f "%03g" 1 30) for i in $SEQ; do wget http://ftp.gnu.org/gnu/bash/bash-4.3-patches/bash43-$i; done But ...
2
votes
1answer
180 views

How to remove file log with file name

Assume, I have log files with this name format. NameLog.log.2014-09-27 NameLog.log.2014-09-28 NameLog.log.2014-09-29 NameLog.log.2014-09-30 NameLog.log.2014-10-01 NameLog.log.2014-10-02 ...
1
vote
3answers
1k views

Trouble with read line script in Cygwin

I'm on windows 7 using Cygwin. My script and text file are located in the same directory. #!/bin/bash while read name; do echo "Name read from file - $name" done < /home/Matt/servers.txt I get ...
3
votes
2answers
6k views

Bash/Korn shell script edited on Windows throws error '…^M: not found'

Some background on the issue: I am new to scripting and wrote a simple Bash script in Windows using Notepad++. cxStopAllServicesOnSERVER.sh #!/usr/bin/bash cd "/some/path" echo "Hi. Logs can be ...
5
votes
4answers
1k views

Is there any book , Tutorial on very very advanced shell scripting [closed]

I am looking for some tutorial where a simple script is written using very advanced methods so that i can learn more from
6
votes
1answer
560 views

Escape sequences in output of script called from ncurses application

I'm currently running mcabber as my Jabber client (which uses ncurses) in a tmux session on my homeserver. Locally i run iTerm2 as a terminal emulator, which supports the triggering of growl ...
9
votes
2answers
4k views

How to Extract Album Cover Image from MP3 file?

I have a bunch of MP3 files that have their album art included within the file itself. I am now looking for a way to extract them to store them separably, at best from command line. Is there a way to ...
2
votes
3answers
48 views

Hide make targets from shell when users autocomplete in bash

Is there a way to flag some targets in a Makefile so that they don't appear at all in the shell when the user types make and then presses Tab ? I am having a Makefile with too many recipes and I don't ...
0
votes
3answers
54 views

How to run a script in multiple instances ? ( Ubuntu server )

How can I run a script in multiple instances in Ubuntu server? For example, I have a long running script named scanner.sh placed in /usr/bin/, which I wish to run the script in 10 parallel ...
23
votes
3answers
10k views

What is the difference between ~/.profile, ~/.bashrc, ~/.bash_profile, ~/.gnomerc, /etc/bash_bashrc, /etc/screenrc …?

Answers to the questions on SO and askubuntu, along with poking through (and reading headers of) $HOME and /etc/, indicate a number of files that can be used to set environment variables, including: ...
1
vote
1answer
36 views

cd to a child directory of a symlink fails

To build a kernel module, you have to do make -C where -C is cd functionality. As my make failed a lot of times, I found this: [root@ror6ax2 modules]# ls -l /lib/modules/`uname -r` | grep build ...
2
votes
1answer
439 views

KSH styling text based menu using STDERR

Is it possible to format the STDERR in order to have a better looking menu using the select command? I have a simple select select oChoice in $(<tempMenu.menu) ; do case "$oChoice" in ...
2
votes
2answers
48 views

Is there an improved version of “pick” that will work with filenames with spaces?

Is there a version of the pick script that will work properly with spaces in the filenames? This is a tricky question—pick is trivial to enhance to work with spaces in filenames, but the output ...
6
votes
2answers
178 views

sed + how to delete the second character “.” from the line

how to delete the second character "." from the line what I have is this ( but its remove the first "." from output uname -r | sed s'/\./ /' 2 6.18-164.2.1.el5PAE while I need the following ...
3
votes
2answers
189 views

How do I echo a lot of content in a bash script?

I would like to do echo "[this thing]" This thing is \documentclass{article} \usepackage{rotating} \usepackage{pdfpages} \usepackage{verbatim} \usepackage{amsmath, amsfonts, amssymb, textcomp, ...
3
votes
3answers
262 views

How can I open a file that results from grep?

I often grep a bunch of files to find a line, and then grep returns one result. Rather than copying and pasting the filename into a new command, I'd like to be able to open that one result with an ...
1
vote
1answer
57 views

rpm + where RPM installed the files/scripts PATH

I installed the following RPM file rpm -Uvh --repackage /var/tmp/bash-3.2-33.el5_11.4.i386.rpm warning: /var/tmp/bash-3.2-33.el5_11.4.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186 ...
6
votes
5answers
2k views

How to make bash put prompt on a new line after cat command?

What I get: host:~ user$ cat example.txt some texthost:~ stas$ What I want to get: host:~ user$ cat example.txt some text host:~ stas$ Is there a way I can make cat behave like this? I'm using ...
0
votes
4answers
47 views

Bash multiple rename in one line: is possible?

Is possible to rename and substitute on fly with bash? for example i have VTS_01_1.VOB VTS_01_2.VOB VTS_01_3.VOB I want to rename for use in mencoder with movie_1.avi movie_2.avi,etc.. I ...
4
votes
1answer
336 views

Write default array to variable in Bash

I was expecting excludes="${excludes:-( ${default_excludes[@]} )}" to be an array if $excludes is empty. Unfortunately the stuff after :- is taken to be a string. Did I miss some syntax contortion, ...
8
votes
2answers
10k views

Why doesn't my ~/.bash_profile work?

I'm using Linux Mint. My login shell (cat /etc/passwd | grep myUserName) is bash. After I start my graphical desktop environment and run terminal emulator from it, I could see that .bash_profile is ...
4
votes
2answers
28 views

Long start time of MC due to bash function

I have next bash function to ensure new-lines after commands: user at terra in ~ $ echo "m" m user at terra in ~ $ echo -n "m" m↵ And the function itself in a .bashrc: function prompt_command { ...
0
votes
1answer
45 views

Trying to multiply a float in bash not working [duplicate]

I have this script that is to rescale images to a percentage value #!/bin/bash percent=$1 echo $percent for img in `find *.png`; do echo Processing file $img width=$( mdls $img | grep ...
4
votes
3answers
328 views

How to call a service URL from bash shell script in parallel?

I have a service which I am calling from another application. Below is my service URL which I am calling - http://www.betaservice.domain.host.com/web/hasChanged?ver=0 I need to do some load test ...
2
votes
3answers
63 views

Redirect stderr to a file, but create only if any stderr happened? [duplicate]

I'm running a command like: parallel --spreadstdin --line-buffered 'some_command 2> `mktemp --tmpdir /tmp/stderr`' | do_something The trick is that parallel creates a lot of processes and they ...
7
votes
1answer
1k views

How does `env X='() { (a)=>\' sh -c “echo date”` work?

After reading about the latest bash vulnerability, I was wondering how Tavis Ormandy's exploit works. How does (a)=>\ work? He posted: The bash patch seems incomplete to me, function parsing ...
3
votes
2answers
5k views

Where is the system profile that gets sourced at login on CentOS 5.8?

In CentOS release 5.8 (Final), where is the bash system profile? Is it /etc/profile ? I've added the following to source my ~/.bashrc file but haven't had any luck as it fails. I know it fails ...
1
vote
1answer
31 views

Ran php file contents in bash, could some commands be executed?

I accidently pasted this in bash as super user on production server. Now I'm eating nails. I looked through each line and most of them produce syntax error. But is there something evil that could ...
3
votes
2answers
196 views

place the aliased version of an existing command in /usr/bin/

I use Vim a lot, and I know how I can start vim in insert mode. So I have an alias named vii in my .bash_aliases file. On other hand I use Git a lot too, and I have this line in my .gitconfig: ...
1
vote
2answers
52 views

A tiny and simple script fail and this is the output “No such file or directory”

The script is: #!/bin/bash IFS=" " command="ls /tmp" for file in `$command`; do echo $file done And the output is: $ ./test.sh ./test.sh: line 17: ls /tmp: No such file or directory
2
votes
3answers
95 views

Call sed to replace a string stored in a bash variable

I want to expand a variable in bash with sed or awk. This variable is an array. For example, the script must delete strings contained in array. I tried ARRAY1=( string1 string2 string3 ) sed -i ...
0
votes
1answer
1k views

Changing title without changing prompt on Cygwin

I have the following shell script function from this site that allows me to change the title in both Putty and Cygwin. In Putty connected to a Linux host it changes the title and leaves the prompt as ...
0
votes
1answer
348 views

Creating MySQL database and user without password

I am building a set of bash scripts which basically prepare apache virtual hosts, git repositories and other stuff on a cloud server. So far so good, everything is working, but a big problem occurred: ...
1
vote
1answer
36 views

ffmpeg script - slicing a video into multiple slices

I am currently using ffmpeg to slice video files. I automated the process through a script called ffmpeg_split.sh. To view the script click here. When I run the script I have an error when trying to ...
1
vote
2answers
72 views

how to shuffle characters of strings in bash?

i have this script where it generates random password but it needs to be shuffled. I couldnt find a way to do it. Please Help me. num=("0" "1" "2" "3" "4" "5" "7" "8" "9") special=("@" "#" "$" "%" ...
4
votes
3answers
406 views

Why does bash have a HISTCONTROL=ignorespace option?

Or to phrase it differently, why would you want to prevent commands from being written to the bash history? (Inspired by a related question.)