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

0
votes
0answers
6 views

[REQUEST]File joining script on android device

I'm seeking for help in part of a java\android project I'm working on I need a bash script that can run on an android device, I don't have enough understanding of bash language so I'm asking for a ...
0
votes
0answers
10 views

What are potential problems for installation scripts modifying .bashrc

Some software packages advices you to make an alias for a certain program,... in other words modifying the ~/.bashrc, ~/.profile files. Little of these packages have an installation script that make ...
0
votes
3answers
66 views

Concat 1000 files within a directory [on hold]

I know we can concat files by cat file [file] [[file] ...] > joined-file. I have directory which contains lots of files. I want to concat all of them. I want to concat 1000 files irrespective of ...
2
votes
3answers
53 views

Extract two values from the output of a command

I'm using the following command in a script to get synthetic wifi info: echo "$( iw dev wlp1s0 link | grep '^\s*SSID:\s' | sed -r 's/^\s*SSID:\s//' ) $( iw dev wlp1s0 link | grep ...
2
votes
3answers
40 views

How can I prepend and append to each member of an array?

I have an array: CATEGORIES=(one two three four) I can prepend to each array member using parameter expansion: echo ${CATEGORIES[@]/#/foo } I can append to each array member the same way: echo ...
0
votes
1answer
33 views

Test variable in a bash case statement

What I want is simply to do something if the first variable of the script is empty, in a case statement. Unfortunately I spent yet a certain amount of time searching for the solution but didn't find ...
0
votes
2answers
24 views

Timeout function return value

I'm using the timeout function on debian to wait 5 seconds for my script. Works great but the problem I have is that I need a return value. Like 1 for timeout and 0 for no timeout How am I going to ...
3
votes
0answers
33 views

Bash Script — ffmpeg not being invoked as expected

I'm working on a bash script to convert my music library to ogg* but executing the right command is somehow eluding me. This is the line that should accomplish it: ffmpeg -i "${file}" -f flac pipe:1 ...
0
votes
0answers
16 views

Why “killproc” command is unable to terminate a script(whiled loop with inter sleep)? [on hold]

How to terminate a whiled loop script using "killproc" without using script's pid?
0
votes
3answers
48 views

bash: Assigning the first line of a variable to a variable

I have a multiline variable, and I only want the first line in that variable. The following script demonstrates the issue: #!/bin/bash STRINGTEST="Onlygetthefirstline butnotthesecond orthethird" ...
0
votes
0answers
18 views

How can I copy the previous argument for the *current* command? [duplicate]

I can use Alt+. or !$ to get the last argument passed to the previous command, however, is it possible to get the last argument passed to the current command? For example, something that I do ...
0
votes
1answer
19 views

Help killing off Process for Mem Leak

I am currently building an Android LP kernel, and have some pretty sweet tweaks already running and built into it. I know there are numerous LP memory leaks (i've already got the bootanimation one ...
0
votes
1answer
38 views

SSH: remote variable

I want to run a complex script via ssh #!/bin/sh ARRAY1=( server1s server123 server12 server14 server13 ) for i in ${ARRAY1[@]};do ssh $i " case \$HOSTNAME in server1.domain.com) echo try1 ...
-1
votes
1answer
31 views

Webpage content - search for pattern & save to file

I have a web page, say https://test.salesforce.com. I would like to search for a pattern, e.g. "src" at the beginning of a line in the entire webpage content. If the pattern is found, I need to ...
1
vote
1answer
12 views

getting case insensitive completions with compgen in bash

I'm trying to get my command (devmode2) auto-completing with bash working with compgen -W, my bashrc has: _devmode2() { COMPREPLY=() local sonames=$(devmode2 --auto --current "${COMP_CWORD}" ...
0
votes
2answers
55 views

export PATH permanently [duplicate]

I have exported the PATH but once I switch to a different terminal or reboot Debian, $PATH is reset. Here are the steps I take: ~$ vim scripts.sh #!/bin/bash echo "Hello" I save it as mybash.sh ...
0
votes
2answers
29 views

Generate a list of installed PHP extensions

My goal is to write an as simple as possible (but not more simple) that generates a list of currently installed PHP extensions (*.so files) that the user can simply copy/paste into their php.ini. It ...
0
votes
2answers
23 views

Get or filter duplicated lines by column

I have a file with three columns and I would like to get duplicated lines by third column, for example: AAA = 342 BLABLABLA = 2 BBBx2 = 23 1+1 = 2 KOKOKO= 5 2x1 = 2 The output sould ...
0
votes
0answers
15 views

bash show-all-if-ambiguous turns on spontaneously

I am using tmux and bash. I find that, at seemingly random intervals, my running shells have show-all-if-ambiguous set to on. This is a significant annoyance to me, since many of my operations are in ...
2
votes
1answer
42 views

How do I properly escape this long su + sed command?

#!/bin/bash wineuser=tom su $wineuser -c "sed -i '$ialias ptgui "wine ~/.wine/drive_c/Program\ Files/PTGui/PTGui.exe\"' /usr/people/$wineuser/config/cshrc.csh" The acutal line inserted to tom's ...
1
vote
0answers
37 views

Shell Script to change user shell

I am writing a script that would be invoked to change user shell. The basic requirement is that once user gets authenticated (e.g: thorough some web application) the script would be invoked to set the ...
7
votes
3answers
256 views

Does while spawn a subshell in bash? [duplicate]

Can someone explain why this script doesn't produce the output I was expecting? #!/bin/bash # var=0 ls -1 /tmp| while read file do echo $file var=1 done echo "var is $var" I get a ...
2
votes
3answers
53 views

Bash | port killing loop fails

I am trying to create a bash function which should kill all processes using some ports specified in port_array. The kill-port function works if I call it myself with a port e.g. with kill-port "80";. ...
1
vote
0answers
25 views

Inherit IO redirections from a script to another

When I redirect the output of a script within a script, I expect the redirection to be applied to the called script as well as the program called within it. A: ./B 2>> error.log B: ...
2
votes
3answers
144 views

Add extension for multiple files, based on their types

I know that there are many questions about adding extension to a multiple files. But none of them could get my job done. I have a huge list of images without extension, most of them are png, but ...
3
votes
4answers
88 views

Run multiple commands and kill them as one in bash

I want to run multiple commands (processes) on a single shell. All of them have own continuous output and don't stop. Running them in the background breaks Ctrl-C. I would like to run them as a single ...
0
votes
1answer
20 views

How do I run the query 1 by 1 and return only exit code in bash script? [on hold]

I've created a below script :- query1=$(command1) query2=$(command2) query3=$(command3) if [ $? -eq 0] then echo "Success" exit 0 else echo "Failed" exit fi the problem is when I ...
0
votes
0answers
37 views

Output of wc | awk is different in shell script than from cli

When issued via command line, this returns "2": pgrep someprocess | wc | awk '{print $1}' When run in a script like this, it returns "4" #!/bin/bash SOME_PROCESS=`pgrep someprocess | wc | awk ...
1
vote
0answers
12 views

Run a query and Send out email

I created a script to monitor and have a query as below :- httpUrl="http://some.website.ashx" balExp=$(curl -v -X POST -d "UID=test&PWD=2222" $httpUrl) How do I sent email alert (my email ...
4
votes
4answers
208 views

How can I copy a file in a bash script and rename it while copying and place it in the same directory

How would I copy a file "file.doc" and rename it while copying to "file_copy.doc" and place it in the same directory ? And this only by calling the script and adding the file name in the argument: ...
-3
votes
1answer
40 views

Help to run a script command from one server on another

I have a go daddy account and also a vps in germany. In my vps, i run a code script (we will call it codegen) when i run ./codegen i get my question of how many codes do i want to make and with that ...
2
votes
1answer
43 views

Why sudo env is not showing all the environment variables?

I have a variable set in a script file in /etc/profile.d/somescript.sh I have modified the /etc/sudoers and added "ansible" user to the sudoers file like this: Defaults !env_reset ansible ...
1
vote
1answer
27 views

Bashrc PS1 error

I created a nice PS1 for bash with http://bashrcgenerator.com/, but something seems to go wrong. The terminal emulator shows me some random, characters which means that PS1 probably has a syntax ...
0
votes
0answers
36 views

use result of last line in bash [duplicate]

-> which vim /home/spo/Home/Platform/Linux/Module/Vim/Bin/vim su spo $RESULT_OF_LAST_CMD /etc/fstab What is the bash variable that holds the last commands result , like google chrome terminal . ...
3
votes
3answers
202 views

How to move subdirectories into another subdirectory within the same directory?

There is a directory dir/. It contains subdirectories a-z. I need to move subdirectories a-y into subdirectory z. If that's hard, then not a-z, but by providing a list of directories that need to be ...
6
votes
4answers
255 views

All possible combinations of characters and numbers

So I want to do generate all possible combinations of lower and upper case characters and numbers that can make up a 5 character string. Possibilities: a..z, A..Z and 0..9. Is there any elegant way ...
1
vote
1answer
15 views

Store command output from openssl?

Im writing a script where I'm trying to verify certificate passwords. This is what I had in mind. passtest=$(openssl pkcs12 -info -in $CERTPATH -passin pass:$certpass) if [[ $passtest == *"invalid ...
0
votes
1answer
35 views

How to pass variable into parallel script from text file line by line

I need to read a file line by line and pass the string as a variable for a script to be run in parallel. ex: 14 43 57 is in foo.txt if I var=$(cat foo.txt) then I can use this $var for inside a ...
1
vote
1answer
30 views

read reading input devided by spaces

How can I read in POSIX bash input like this: <name>,<tag1> <tag2> <tag3>… I tried while read line;do done but this wants newlines, all I have is spaces. (Is IFS solution? ...
1
vote
1answer
46 views

A question about shell and .profile,.bash_profile,.bashrc

I'm on aix 7.1,my shell is bash if i did ssh ibmunix gqlplus user/pass All works and gqlplus start,gqlplus is on /opt/freeware/bin If i did from another machine ssh ibmunix "gqlplus ...
7
votes
1answer
130 views

Why there isn't a new line at the end of quoting a subshell and passing the results to echo?

When I do ls | grep png the output of grep is: 2015-05-15-200203_1920x1080_scrot.png 2015-05-16-025536_1920x1080_scrot.png (filename,newline,filename,newline) then, echo $(ls | grep png) outputs: ...
0
votes
0answers
31 views

Shell Scripting - return to previous loop until process is completed then die/done

I am writing a bash/shell script to automate some file filtering functions. I am stuck due to being new to scripting and I am not sure how to code the function in it to keep looping the top section of ...
-2
votes
0answers
45 views

Convert perl to shell/bash [closed]

I understand C and C++ and new to perl scripting. I must convert the perl script under the following url to shell or bash: busware Here is the code: #!/usr/bin/perl use warnings; use strict; use ...
2
votes
4answers
90 views

Why . /home/Desktop is incorrect and ./Desktop is correct?

I'm learning about Linux, started yesterday. I have a question which I couldn't answer from my book or Google. What is the difference between ./ and / in the shell? I'm asking this because when I ...
-1
votes
1answer
28 views

Add git information to a bash prompt with colors

I set my PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ ' I followed this link, to setup my git. And I lost the color of my prompt. If I remove the variable, the color comes back. I am using Xubuntu, 15.04, ...
2
votes
0answers
15 views

Context-sensitive bash completion changes wildcard behavior

Somewhere along the way I've fallen into the habit of hitting tab twice after using a wildcard in commands like mv or rm, which by default causes bash to show the list of files that would match the ...
9
votes
2answers
59 views

Is flock & exec safe in bash?

The "standard" locking snippet I've seen goes something like... ( flock -n 200 || exit 1; # do stuff ) 200>program.lock Is it safe (testing seems to say so) to use exec at that point? ...
0
votes
2answers
63 views

bash: xport: command not found

I have used export to change my PATH variable. export not xport, but now every time I open a terminal I get this error: bash: xport: command not found [mirko@localhost ~]$ I tried removing ...
0
votes
0answers
19 views

Issues with Screen - Running Minecraft in a while loop through a screen session

So two days ago I changed my startup scripts for my minecraft server. Problem is, after about 3 hours, the screen for it that I was monitoring "mc" vanished and refuses to list when using -ls. The ...
0
votes
2answers
44 views

how to continue bash script execution when expect part is finished

I have bash script and inside it part with expect code: #!/bin/bash set -ex funct() { pass3="some_pass" expect -c " spawn su - oracle expect "Password:" send \"$pass3\n\" ...