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

learn more… | top users | synonyms

0
votes
1answer
18 views

Extract each digit of variable and store as new variable in bash

I have a variable that is a number ranging from 1 - infinity. Lets say the number is 40. I need to store 4 as a variable, and 0 as a variable. Since the number can grow beyond 2 digits, lets say the ...
0
votes
1answer
19 views

Why does this bash file stop my tomcat if the session closes?

The following bash script starts an Apache Tomcat and tails the log file to the screen: #!/bin/bash ~/tomcats/TC1_8083/bin/startup.sh tail -f ~/tomcats/TC1_8083/logs/catalina.out If I CTRL-C the ...
0
votes
1answer
24 views

What is the best / common practice to include a function that is used from several scripts?

I currently did this by sourcing a functions file including all my functions into the several scripts that use it: source ./functions.sh One disadvantage I noticed is that the line number bash ...
0
votes
1answer
42 views

Multiple Conditions in shell script

Im stuck in giving two conditions in my script. I can read two things - What is the NEAREST SERVER If it is MacBook or Anything Else and then use defaults write command to modify the plist file. ...
0
votes
1answer
35 views

How to open git for windows shell inside a tab on ConsoleZ

I have used git bash 1.9.5 from https://git-scm.com/download/win on ConsoleZ as shell and have no problem on open him inside a tab. But, with the new Git for windows 2.4.5.1 RC4, it open always in a ...
0
votes
1answer
24 views

How to store data from different netcat connections in separate files?

I need a server that should receive data streams, store them in files and send further. Each connection should create a file with corresponding timestamp in file name, then write to it. My solution: ...
0
votes
1answer
17 views

Variable as argument to Wine

The variable $INPUT_FILES in Case 1 has the same content (string) that is used in Case 2. Why in Case 1 I have problems with spaces in the name "2015 01 09.1.txt", but in Case 2 not? How can I fix ...
0
votes
1answer
74 views

What does this bash script?

In theory, this snippet from pentoo-installer finds all partitions on the selected disc, but it doesn't find my sda1 partition, so I would love to understand it and modify so it does. ...
0
votes
1answer
49 views

How to recover the Linux VM after accidentally deleting all root folders?

I have a CentOS Linux VM running in VirtualBox. I wrote a bash script to do some automated tasks. But I accidentally deleted all root folders because I put a line in the script rm -r $my_dir/* ...
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
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
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
1answer
30 views

How to load config file via git?

I suspect this is a silly question, but I haven't been able to find an answer online. I'm trying to load a config file in git, but the file is not in one of the default storage locations. So I tried ...
0
votes
1answer
27 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?
0
votes
1answer
21 views

script a list of websites to determine ciphers

Have a list of websites I would like to check the ciphers. We will be using SSL decryption and want to see if I can in advance check the sites that will not support our decipher. We have some ...
0
votes
1answer
17 views

ChkTex on Windows

I'm trying to install the SublimeLinter-chktex package for Sublime Text 3 on Windows 8.1. As part of that I need to install Cygwin and ChkTex. Following the instructions, I have first installed ...
0
votes
1answer
31 views

Parse csv file and for each object set as a variable

What I'm trying to do is parse a csv file that has server names and ipaddresses and assign these to variables I then run commands using each set of variables. So if the cvs file, test.csv, looks like ...
0
votes
1answer
68 views

Script that scans my network

I have a question I want to run a script that scans my network and that I can see with devices are up in my network. I want to paste some arguments also in the script When I run the script: ...
0
votes
1answer
65 views

How do I run Asterisk as user other than root?

I compiled Asterisk 11 from source as user root on CentOS. Now I want Asterisk to run as user asterisk group asterisk. I have uncommented AST_USER="asterisk" AST_GROUP="asterisk" in ...
0
votes
1answer
23 views

Can bash reverse history search (Crtl+R) be configured to NOT delete history?

I find Ctrl+R very useful, however I am really anoyed that when I press the backspace key, it deletes the currently matched entry in the history. Is there a way to disable this ?
0
votes
1answer
24 views

create and run bash script on start of runlevel5

I have created a following hello bash script: #!/bin/sh echo "Hello Run Level 5" I put this script in the /etc/rc.d/rc5.d directory with a name S100RunLevel5. How can I make this script to run ...
0
votes
1answer
38 views

How to recursively compress subdirectory's files with password

I need to recursively compress subdirectory's files with password and then delete the uncompressed file in bash file. There are zip files and other files. I don't want to compress zip files again. I ...
0
votes
1answer
11 views

Distribute session-only git configuration on ssh login

I have a bunch of development servers (linux) that I connect to via SSH from linux workstation. On most of these servers I want to use the Git command line interface. I use a set of Git aliases that I ...
0
votes
1answer
31 views

Refer to Wildcard in File Name

I know I can use a wildcard to extract files with names of a specific format in bash using the asterisk, like so: $ ls a01 a02 a03 a04 a05 a06 a07 a08 a09 b01 ...
0
votes
1answer
35 views

How to grep through HTML using GNU grep 2.12 and bash 4.2.37?

I've never used grep to parse HTML files, and am having the following problem: grep -Po "(?s)(<h2>.+?<!-- /endcontent -->)" input.html > output.html -bash: !--: event not found I ...
0
votes
1answer
23 views

separate mappings for TAB and C-i in .inputrc

For what I have tried, "TAB" and "C-i" in .inputrc seems to mean the same thing, whatever I bind to one is bound to the other. I know that originally, it was the same thing and that this behavior is ...
0
votes
1answer
29 views

FreeBSD bash history: can't access last symbol of command

There's an old server I am working with, runs modified FreeBSD 6.1 with bash 2.05b.0(1)-release. On 'up' key press the last command from history pops up - but I can't access the last symbol, like the ...
0
votes
1answer
29 views

How to edit one file, but have it update in two places?

What I'm trying to do is make my computer automatically update my backup files when I edit my local files. For example. I have a directory of websites I work on. Each site is its own directory. I ...
0
votes
1answer
152 views

Tool(s) “patch” is(are) missed, please install it(them)

I am using xampp in Windows 8. I want to install magento security patches in local magetno. To run command I have install Cvgdrive but when I run the following command I am getting an error. bash ...
0
votes
1answer
44 views

Run .sh in cygwin script from cmd

I have a .bat script that calls some .exe to generate text files: generate.bat: ... ResGen main.txt Main.resources /str:c# ... After that, I want to use vim's commandline search/replace on the ...
0
votes
1answer
32 views

Website updating from git (over ssh)

I have a script that I run over SSH, which updates my website from a Git repo. cd website-git git checkout master git pull # Update protected directory rsync -v -a --delete --exclude=db ...
0
votes
1answer
88 views

Rsync delete only remove older source files

Ok, I could probably spend a lot of time writing a complex set of bash scripts that would accomplish this, but I'm hoping this functionality already exists somewhere. I have a device in my car which ...
0
votes
1answer
79 views

CPU Load + Frequency per core in linux terminal?

I am doing scientific computing and I need to keep an eye on the cpu frequency and load of each core (there are 2 cores, on Ubuntu 14.04 w/ Gnome3). I can see the frequency with this bash script: ...
0
votes
1answer
29 views

Cronjob: Iterate through files

I want to iterate through a list of bash scripts with a cron-job. I.e. every two hours I want to start another bash script. My idea was to set a new environment variable, each time the cronjob script ...
0
votes
1answer
105 views

Output of the ps command and understanding the flags

Ubuntu 12.04 LTS using bash. I tried running the ps command from a Java program using the Runtime and got some unexpected output. Upon closer inspection I realized that it was the output of: ps ...
0
votes
1answer
46 views

Wget not getting cookies, not pulling back results in check.

I'm having a couple of issues when porting check scripts between a couple of servers. The script. #!/bin/bash hostname=$1 port=$2 retstatus=0 retStr= st=`date "+%s.%N"` if [ $# -ne 2 ]; then ...
0
votes
1answer
44 views

How to move unopen files to another folder

I´m beginner in Linux and I want to build a script in bash to check which files are open in a folder and move any other files - those that are not open to another folder.
0
votes
1answer
104 views

Start PuTTy session in remote host over network

I have 5 hosts - A, B, C, D and E. A and B are windows hosts. C, D and E are Linux machines running ssh server on port 22. I've copied plink.exe (putty command line backend client) in host B. When I ...
0
votes
1answer
47 views

Get the Group name which has GID=0

I wanted to write a shell script in which it needs to give the group name whose GID=0.I used awk command like this, awk -F ':' {$3==0} /etc/group | cut -d ':' -f1 It works fine in redhat,aix.But ...
0
votes
1answer
20 views

What is KNOPPIX shell's start-up file?

I'm trying to install virtualenvwrapper and I got to change the settings of my shell's start-up file (like .bashrc, .zhrc, .profile, etc) to write this: export WORKON_HOME=$HOME/.virtualenvs export ...
0
votes
1answer
226 views

Test USB 3.0 Device Speed

I've looked up hdparm, but all examples are for testing disks. Not sure if it can be used to test external usb devices (specifically usb flash stick). I'm using the following code right now: dd ...
0
votes
1answer
147 views

Mac OS X seems to be unable to find directory that certainly exists

For some reason Mac OS X cannot find a directory I just made. Any idea why? sh-3.2# mkdir /Users/Administrator/Documents/drive/ sh-3.2# mount -w -t "hfs+" /dev/disk1s2 ...
0
votes
1answer
78 views

Script to delete all non-admins with launchd or logout script on OS X

I've found a number of articles that touch on this subject but they are not running for me or perhaps because they are years old they do not work OS X 10.10 Yosemite. In short we run Deep Freeze but ...
0
votes
1answer
24 views

My bash_prompt cannot find a shell script

This is a function I added to my .bash_prompt function look_for_autorun() { echo "checking file" FILE="autorun.sh" if [ -x $FILE ] then echo "File '$FILE' Exists" else ...
0
votes
1answer
44 views

$RANDOM in script vs. on command line

I think I found a really odd bug in Bash's random number generator ($RANDOM). Showing is easier than telling, so here's what happens: The goal is to get random digits. If I execute this, I get 20 ...
0
votes
1answer
169 views

bash- how can I use wget to send POST data with files?

I want to make following POST request to my server using wget: email=abc@abc.com&file1=@FILE_HERE&file2=@FILE_HERE In above request, there are three POST parameteres called email , file1 ...
0
votes
1answer
21 views

Keyboard shortcut to kill a script containing multiple wgets?

I have a Python script that wgets a load of files: for year in range(2010, 2015): for month in range(1, 13): filename = url filename += "/T%s%s_BNFT.CSV" % (year, month) ...
0
votes
1answer
60 views

Bash - Parsing XML output of nmap

I am trying to write a bash script that will take port id I retrieve from an nmap command, and then use those ports to send a file using netcat. So I got some basic knowledge using this link, How can ...
0
votes
1answer
11 views

CentOS6 Backup fails; “permission denied”

I am currently trying to do a backup of a server and am getting an error message when running my script. The script runs correctly on certain directories, but for the directory I am attempting to use ...
0
votes
1answer
95 views

How to handle a condition when an expect script executing another script on a remote host is interrupted?

Im using an expect script to say xyz.exp to login to a remote host and execute another script abc.sh Now most of the times abc.sh runs fine, but there is a scenario where if a certain condition is ...