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

1
vote
3answers
40 views

How to get the pid of a process and invoke kill -9 on it in the shell script? [duplicate]

I have an application server which we start by running this below command and as soon as we run the below commnad, it will start my application server /opt/data/bin/test_start_stop.sh start And to ...
-2
votes
0answers
10 views

UNIX .vimrc settings not preserved after running Screen command

After the terminal window first appears, I run Screen to split the screen horizontally. I notice however that my settings for VIM in .vimrc are not "preserved". Is there a way to fix this? I am ...
1
vote
1answer
58 views

Why are UNIX shells like this and how can I work around it?

One of the things I've noticed about BASH and other UNIX shells is that, by default and when used in typical ways, they spawn subshells for almost everything. e.g. foo=$(grep "someword" ...
0
votes
2answers
24 views

Permanent header in bash terminal

I'm working on a small server I want to put together (nothing big, an Android HDMI dongle, running Debian armhf, no desktop, just remote), and I want a small little feature I've seen at a few places ...
2
votes
2answers
30 views

List of subdirectories that contains a particular file name

I am wondering if i can do this in a single shell command. I am in home directory and want to find a list of subdirectories that contains a particular file. The file name and the depth is always ...
3
votes
2answers
120 views

using modified file content as arguments

In a script I'd like to purge a mercurial repository but be able to retain a number of (configurable) file patterns which I read from $FILENAME. The syntax for the hg command is hg purge --all ...
1
vote
0answers
21 views

Why can't I use tab expansion/auto-complete of shell variables with cd?

I have setup a variable in .bashrc: export SOME_DIR=/path/to/some/dir Now, with ls I can type ls $SOME_DIR[tab] and the variable will be expanded, and I can then use tab for auto-completion when ...
0
votes
1answer
20 views

Disabling a keyboard key in console

I wrote a script that dialog command is vulnerable to Esc key, now I want to disable Esc key in console. NOTE: X11 has been not installed in server and xev or xmodmap doesn't work.
0
votes
1answer
22 views

How do I switch from bash to zsh? [duplicate]

I can start zsh with zsh. How can I make it be the default for new terminal windows? Will it be ok to copy my .bashrc to .zshrc to get things like my customized PS1 prompt.
1
vote
2answers
36 views

How does bash pass user groups to a child?

It is well-known that if I add myself to a new group, that change will not be reflected until I log out and back in: $ sudo adduser me newgroup $ groups me sudo $ groups me me sudo newgroup $ This ...
1
vote
3answers
65 views

How to find md5sum of files on remote machines by doing ssh?

I am running my below shell script on machineC which gets the md5sum of my files in my PRIMARY directory in machineC itself. #!/bin/bash export PRIMARY=/data01/primary for entry in "$PRIMARY"/* do ...
0
votes
1answer
24 views

Permission denied while getting the md5sum of a file using shell script?

I am running my below shell script which gets the md5sum of a files in my PRIMARY directory #!/bin/bash export PRIMARY=/data01/primary for entry in "$PRIMARY"/* do local_md5sum=/usr/bin/md5sum ...
0
votes
2answers
24 views

When executing a script via ssh, how can I transfer variables back to the PC issuing the cmd?

I'm writing a pretty simple script that will SSH into the machine of my choice, run a script to obtain things like the number of users logged in, CPU averages, etc, and write it to a file on the PC ...
0
votes
2answers
34 views

Bash script: test command -o option

I have a piece of code like this: count=0 until [ -f $filename -o $count -ge 60 ] do count=$((count+1)) sleep 1 done I know [ -f $filename -o $count -ge 60 ] is a test command, "-f $filename" ...
2
votes
1answer
39 views

Bash - how to make explicit operator precedence without creating a subshell

I'm sure this is posted somewhere, but I haven't been able to find it. In Bash, how does one specify operator precedence (aka command grouping) without creating a subshell? In most other languages ...
1
vote
0answers
62 views

HISTSIZE HISTFILESIZE not working

I have set these global variables in my .bashrc file Running echo $HISTSIZE echo $HISTFILESIZE both return 10000 My History contents are overding, currently from 254 - 432 If I type another two ...
2
votes
1answer
27 views

Is there a way to express fixed size loops as loop-less expansion statement in bash?

I was wondering whether expansion of {} in bash shell, e.g. of command /path/to/file{1,2,3} works "horizontally", i.e. command /path/to/file1 /path/to/file2 /path/to/file3 or "vertically", i.e. ...
0
votes
3answers
153 views

How to add a password to a specific command

I've been searching google on how to add additional security to a specific command without using sudo. Is it possible to add on a security feature without actually using sudo? For example: Whenever ...
2
votes
1answer
21 views

Single or double brackets and portability

I have found some very good answers here on the differences between [ and [[ in 'if' statements. For specific named shells, it seems to be a good idea to use [[ over [ (and it is faster, too). I'm ...
0
votes
3answers
103 views

How do I substract 5 minutes from a Unix timestamp?

I have a date in milliseconds since Unix epoch format, how do I substract 5 minutes from it?
1
vote
1answer
38 views

How do I convert a date to milliseconds since Unix epoch in bash?

I've got a date in format: 22-Sep-2014 10:32:35 I need a 13-digit timestamp, but when I convert this way time=$(date -d "$DATE" '+%s') I get a 10-digit number When I try tt=$(date -d ...
0
votes
1answer
35 views

How to invoke shell function in string? (bash)

I want to invoke shell function in string. Here is my use case: function envfoo() { env ENV_FOO=foo $@ } function envbar() { env ENV_BAR=bar $@ } $ envfoo env |egrep ENV_ ENV_FOO=foo $ ...
2
votes
2answers
42 views

How to run the dialog command with proccess?

NOTE: Please look at my code, it's a Bash script. I want to display both dialogs on the screen at the same time, one dialog displays this: tail –f from - /var/log/proccess1.log and the second ...
-1
votes
1answer
38 views

Match and combine records in Bash [duplicate]

Consider two csv files: $ cat given.csv 123,John 246,Paul 369,George 987,Ringo $ cat family.csv 246,McCartney 123,Lennon 987,Starr 369,Harrison Note that the lines are not ordered! How might I use ...
6
votes
1answer
51 views

Format cputime for ps

I'm trying to write a script that can monitor a process's CPU usage over an interval (to create a graph). So far, this is the command I'm using ps -p $PROCID -o cputime,etimes My only concern is ...
5
votes
3answers
93 views

Bash script error with strings with paths that have spaces and wildcards

I am having trouble getting the basics of Bash scripting down. Here's what I have so far: #!/bin/bash FILES="/home/john/my directory/*.txt" for f in "${FILES}" do echo "${f}" done All I want to ...
0
votes
1answer
37 views

How to take screenshot of /dev/pts?

I am connecting to another server using ssh service. I want to execute some commands (like creating users) on some servers and take the screenshot of the pseudo-terminal, which is to be stored on my ...
2
votes
2answers
26 views

Gather job usage information on cluster

I am running simulations on a linux cluster shared by hundreds of other users. There is a job scheduler installed on the cluster that determines who runs where, and one of the scheduler commands ...
3
votes
1answer
42 views

Get a list of applications that are playing sound [on hold]

I want to get a list of applications that are currently playing sound (using the sound card). I tried to search on a lot of places but did not succeed. Any method is fine (bash, Java, etc.). I want ...
3
votes
3answers
155 views

Having an issue searching for a string in a file

I have tried to use a 'case' loop but it doesn't work for a reason unknown to me. This is my script for the case loop. echo "Do you wish to search again? [y/n]" read INPUT_STRING2 case ...
0
votes
3answers
127 views

bash find using variable

I have an issue I don't understand. It is simple and it should work, but it doesn't. =EDITED exactly what I can see from terminal= I have a list of filenames: [molni@archlinux picasa_album]$ cat LIST ...
0
votes
0answers
28 views

Is it possible to set the users .gitconfig (for git config --global) dynamically?

I have the problem, that we login to the systems as our own users johndoe and then have to do a sudo su - root to be able to do administrative tasks. We have the system config files in a git ...
0
votes
2answers
9 views

How can I sudo su and change directory just after?

I would like to create an alias that does something like this: alias userYYY='sudo su userYYY; cd /a/path/that/only/userYYY/has/access' So then from my command line, I am logged in with a sudoer ...
0
votes
0answers
48 views

what is hexa dump and how to handle in unix? [on hold]

I am trying to extract some portion of text from the file by using awk command, The file is separated by comma. awk -F, '{print $1 FS $3 FS $6}' sample.csv But always I am getting wrong output , ...
1
vote
0answers
32 views

tput command + how to locate dialog window on the top of the screen

Is it possible to use the tput command in order to place the dialog window on the top of the screen ? For example The following dialog command display the log is running by tail command dialog ...
2
votes
2answers
83 views

bash how to remove options from parameters after processing

I remember having seen somewhere a bash script using case and shift to walk through the list of positional parameters, parse flags and options with arguments when it encounters them, and removes them ...
0
votes
0answers
31 views

bash + timer in dialog window

is it possible to insert the following code ( timer ) in the dialog progress bar ? date1=`date +%s`; while true; do echo -ne "$(date -u --date @$((`date +%s` - $date1)) +%H:%M:%S)\r"; done ...
0
votes
0answers
26 views

How to modify ENV in Solaris 10 [duplicate]

I wanted to edit the contents of environment when entering this "ENV" in terminal. I googled this but so far none of the solution offered works in my end. The closes solution that i got was to edit ...
0
votes
3answers
54 views

Solaris jdk 7 installation error java -version No such file or directory

Am trying to follow this website for instruction on how to install jdk for Solaris 10 with the following information: $ isainfo -v 64-bit amd64 applications ssse3 tscp sse3 sse2 sse fxsr mmx ...
1
vote
3answers
35 views

shell script to run on boot on Mac OS X does not run all commands

On OS X, I am trying to use lingon to run a shell script upon booting. I have a file ~/desktop/_admin/boot/bootdocker.sh: #!/bin/bash boot2docker up export DOCKER_HOST=tcp://192.177.59.103:2475 My ...
4
votes
3answers
124 views

Get PID of any command in backgrounded piped sequence of commands

If, in bash, I execute: cmd1 | cmd2 | ... | cmdi | ... | cmdn & where the cmd{1..n} may not be distinct, how do I get the PID of cmdi? Alternatively, how can I signal the cmdi process? (For ...
2
votes
2answers
65 views

Can I trap a clock signal in my bash script?

Could I trap a 5-minute signal inside my script? I imagine something like this, function dosomething { echo "It's been 5 minutes." } trap dosomething SIGNAL-EVERY-5-MINUTES while true do ...
4
votes
1answer
49 views

How to completely detach a process

I want to spawn a process and run it at the top level so that when the shell exits, the process keeps running. I had mistakenly thought that nohup would do this, but when I exit from the shell (the ...
1
vote
0answers
32 views

From a bash script, is there a way to get the keybinding for “Resize window”?

This question is related to another that I asked How do I execute a program in Xfce and make it use another xfwm4 theme other than the default one? However, I'm now trying to get an answer that will ...
7
votes
4answers
239 views

Can I specify a redirected input before a compound command?

Bash lets you specify a redirected input before a command: $ <lines sed 's/^/line: /g' line: foo line: bar Bash also lets you redirect input to a compound command like a while loop: $ while ...
3
votes
2answers
38 views

Creating an alias to Change Directory and have that directory be the current working directory in new terminal tabs

I'm trying to create a convenience alias that will change directories and then start a node server in that directory. I have it working for the most part, there's just one little issue that I can't ...
0
votes
0answers
24 views

how to insert seperate lines ( elemnts ) in parameter [closed]

I have the following csv file more file.csv 1,yes,yes,customer1 2,no,yes,customer5 3,yes,yes,customer11 4,no,no,customer14 5,yes,no,customer15 6,yes,yes,customer21 7,no,yes,customer34 ...
1
vote
2answers
60 views

How to grab output from command in shell script [duplicate]

I'm trying to write a shell script in RHEL which will execute grub-md5-crypt and the user will type their password. Now the problem is how can I grab the encrypted md5 hash displayed to the user in ...
2
votes
0answers
20 views

How do I execute a program in Xfce and make it use another xfwm4 theme other than the default one?

I want to run a python script (the one in the answer to Python - how to make transparent window with gtk.Window but not with Gtk.) that displays a transparent window. I'm running it from a bash script ...
0
votes
1answer
63 views

How to ssh into remote machine and create new user in bash script

I am writing a bash script and would like to ssh into a remote machine and execute the adduser command. This is not working, all that I get is the --help text for adduser when I run the code below. ...