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

learn more… | top users | synonyms

1
vote
2answers
215 views

replace file's content between specific line numbers with another file using BASH

What is the most efficient way to replace file's content between specific line numbers with another file? Here is a sample: main.txt: a b c d e f g h i j k l new.part.txt x y z p q r s t u The ...
0
votes
2answers
287 views

Can't rename volume group in linux that had hyphens/dashes in name

I made a typo when I created an LVM group under Centos 6.4. I'm trying to rename using the syntax vgrename /dev/mapper/oldVG /dev/mapper/newVG. However, both the old and new VGs have hyphens in the ...
0
votes
1answer
87 views

Restricting MSYS (Bash) auto-completion to current directory

I'm using MSYS on Windows 7 and I really enjoy the TAB auto-completion feature of the bash console. However it appears that this feature queries all directories in Windows' $PATH variable, requiring ...
1
vote
0answers
92 views

mergecap fails to create output file when run from crontab

I have created a script to merge pcap files using 'mergecap -w '. The script doesn't work as the output file is not already present. So I tried to use 'touch outputfile.pcap' before the mergecap ...
0
votes
0answers
28 views

Make synchronized folder with TFS in linux

I am using TFS every where on CentOS and I want to run a service to listen on directory modifying this directory represent TFS local folder and for every (add or modify) it mirroring to TFS I tried ...
1
vote
3answers
110 views

How to select a section from a string in using bash

I have an array containing strings which consist of paths to files in the following format: /path/to/file/14561234545_50303.TXT I'm trying to select the section that is after the "1" but before the ...
0
votes
0answers
53 views

How to change definition of HERE DELIM in notepad++?

I am planning to document shell scripts with embedded Perl pod as explained here: http://bahut.alma.ch/2007/08/embedding-documentation-in-shell-script_16.html The problem is Notepad++ has a narrow ...
1
vote
2answers
1k views

Mac Terminal showing bash instead of my username

This makes it hard to know what directory I am in. I installed a version of python for school and now it says -bash-3.2$ instead of MyMacbook: ~$. I'm sure this is really simple, but I know nothing ...
1
vote
2answers
112 views

bash is not deterministicly processing the asterisk wildcard

I accidentally added a user to my system without a home directory (I forgot to put the -d and -m flags in useradd). Rather than deleting the user and starting over I attempted to simply mkdir the home ...
1
vote
1answer
208 views

Download and Run script in Linux Terminal?

I am running Linux. I'm writing an installer in Bash for an application I wrote. The installer needs to be able to download different Bash scripts and run them automatically? How would I go about ...
1
vote
1answer
73 views

inotifywait get only on event when create directory

I want to run service to listen on directory modifying and for every add or file modify run a function but I get more one event from adding directory inotifywait -rm -e create,modify "$dir" | while ...
6
votes
2answers
230 views

What is the modification date ls reports for directories in Bash shell?

When I run ls -l in Bash shell, it lists a modification time for both files and directories. As noted in this thread, the modification time for directories does not reflect all of its contents. It ...
3
votes
2answers
369 views

How do I pipe output to date -d “value”?

I have a date like "2014-01-30 05:04:27 GMT", and if I run date -d "2014-01-30 05:04:27 GMT", the output is in my server's timezone ("Thu Jan 30 16:04:27 EST 2014"). With the use of grep and cut, I ...
0
votes
1answer
130 views

osx - change terminal-color based on user

what i want to achieve : everytime i log onto a machine via ssh with a specific user -> "danger" like ssh danger@somehost i want the terminal to change its background to red, so i have a visual ...
0
votes
1answer
79 views

Check for syntax of BSUB in bash script

I am trying to submit a job via bsub linux utility using this bash script titple launchparse.sh: #!/bin/bash #BSUB -W 80:0 #BSUB -R rusage[mem=4000] #BSUB -J "myarray[101-150]" ...
1
vote
1answer
380 views

Upgrading Chromium OS to Chrome OS mount error

I'm trying to upgrade Chromium OS to Chrome OS with http://goo.gl/4suhf. Unfortunately, when running this script (inside Chromium OS), it says: wget stuff unpacking zipfile RootFS Start: 286720 ...
1
vote
2answers
143 views

Find unique files across 2 drives

I'm trying to compare 2 volumes, which mainly have the same content, but in completely different folder structures. (Around 2 million files.) I want to see which files are ONLY in 1 folder, not the ...
0
votes
1answer
342 views

Why does this bash script give an error on Ubuntu but not OSX

#!/usr/bin/env sh export $NODE_CONFIG_DIR=/Users/full/path/to/script/config cd /Users/full/path/to/script /usr/local/bin/node main The script runs locally on OSX (if I adjust the paths for the local ...
1
vote
1answer
85 views

permission denied in running script

I am running a script but there is an unusual warning: This is what happened in my console #whoami root #ls -l test.sh -rwxr-xr-x. 1 root root 1894 Feb 2 01:58 test.sh #./test.sh -bash: ./test.sh: ...
0
votes
1answer
71 views

SFTP transfer with keys

can somebody explain me how I can transfer files with SFTP over bash and with ssh keys instead of passwords? I use Debian 7 and openssh server. Regards, Akitoyo
2
votes
1answer
63 views

Use a separate history for 'read -e' (readline)

I would like to write an interactive command shell in shell script, for easier adjusting of the iptables firewall. The problem is, that read -e uses the shell history. Is there a way of using a ...
-1
votes
1answer
395 views

What's needed to have a shell script run via HTTP Post request?

I was wondering what is needed to trigger a shell script with a HTTP post request. Being in my home wifi I want to call http://ip.of.host/req?run and have a script triggered on my host. I guess I have ...
5
votes
3answers
11k views

command not found when using sudo

There are a few question on the site that seem related to my problem but I could not find a solution in any of them. My operating system is Ubuntu 12.04. I have mvn installed in ...
0
votes
0answers
57 views

Why does read's timeout break my console?

I have a script that is causing an issue, I've boiled it down to this; #/bin/bash read -t 1 -p 'Wanna continue?' less +F readTimeout.sh echo 'Wont get printed' The original script operated by ...
3
votes
1answer
181 views

How do I safely convert a .gz file to a .xz file

I have some huge files that are currently gzipped and I would like to xz them. I want set up a script to do this, but I want to be careful not to lose the data, i.e. I should never delete the gzipped ...
0
votes
1answer
86 views

can a locally executed script run commands on the remote server?

I've been experimenting with a patching process for deploying files to a webserver. At the moment I'm using scp to get the zipped directory structure onto the webserver and then cp -rf --backup=t ...
0
votes
1answer
45 views

Ubuntu How to delete files older than certain file?

There are several files, How to delete files older than certain file X (order by last modified date)?
3
votes
2answers
526 views

Ctrl+c in a sub process is killing a nohup'ed process earlier in the script

I didn't know whether this belonged on SO (as it is a coding bug) but thought you guys would be more knowledgeable regarding the subtleties of the software used (so maybe even U&L could be ...
3
votes
2answers
88 views

Removing “.” while standing on it

While toying with the file system, I tried the following: mkdir a cd a rmdir . Which results in: rmdir: failed to remove ‘.’: Invalid argument Ok, Mr. rmdir, let me outsmart you: rmdir ../a ...
2
votes
2answers
2k views

Putty: login, execute command/change environment variable, and do NOT close the session

I would like to configure my PuTTY session in such a way that I could login to a remote host, and (a) start bash (b) change the PS1 variable (prompt content) (c) continue work in the session as ...
1
vote
1answer
57 views

Homebrew, spotlight and upgrading software under /usr/bin/

My OS X comes with a version of git installed in /usr/bin. However, this version is older than the official stable one. I would like to upgrade it. Can I use Homebrew to upgrade this version? Or ...
1
vote
3answers
137 views

Quick way to scan for opened ports on local network according to a list

How can I quickly find out whether port 80 is open/listening on a server via a bash script? Normally on all workstations the daemon is running, but sometimes it fails. I use the following command to ...
0
votes
2answers
43 views

how to set up an environment variable that it stores a path along with another env variable but doesnt expands

I want to know how to set up an environment variable that stores other environment variable but these environment variables doesn't gets expanded when I echo instead if I use eval echo then it should ...
4
votes
2answers
272 views

Alias scoping in bash functions

I use a script (which I do not have write access to) that creates a bunch of aliases to set up an environment. I would like to create a bash function to setup my environment, but it seems that the ...
0
votes
0answers
45 views

Why can a non-root user not access Sublime soft link

I like using Sublime text as a VIM replacement i.e. opening from the terminal with an argument. I installed Sublime into /opt/sublime_text/ and within that is the executable I need. I then soft-linked ...
2
votes
2answers
51 views

GNU find include parent directories

I am trying to make GNU find exclude entries UP TO the specified file name. Take this sample tree: ./foo ./foo/another.txt ./foo/bar ./foo/bar/world ./foo/bar/world/test.txt ...
1
vote
3answers
167 views

Why 'whereis' and 'which' don't show me location of command?

What are the reasons why commands like whereis or which do not show me location of command? E.g. I have nvm and want to know where is it located, but none of these command help me to find the binary. ...
9
votes
1answer
200 views

Security concerns of displaying ssh private key

I've made I huge mistake, or at least I think it is: I've "catted" my private SSH key cat ~/.ssh/id_rsa I'm now afraid that I've created a security hole, allowing other users to see my private key ...
0
votes
1answer
25 views

Detecting reasons for scp of glob failing

I am scp-ing some files from a remote host in a script. I want to know if anything fails, most commonly due to permissions issues. The files being copied belong to a different user and sometimes the ...
0
votes
1answer
41 views

Use tmux for managing multiple downloaders as a supervisorctl service?

I have many data-servers I need to download data from via http as soon as it is available. For each server I start a bash "while true"-loop and within that a wget to poll the server for new data. To ...
0
votes
1answer
80 views

how to keep number of files in a folder less than a limit

I'm trying to create a bash script to limit the number of files to a limit of 50000. I want to run the bash script on crontab every 5 min so it can keep deleting the old files when the number of ...
1
vote
1answer
71 views

Injecting a keypress into a tool started by a bash script

I'm writing a bash script to gather some informations about disks and then start the 'nmon' tool to monitor only those specific disks. I start the nmon tool out of the bash script (with -g). To get ...
0
votes
0answers
133 views

Start X in fullscreen

I just installed Cygwin/X for the first time and found the documentation really lacking in noob-friendly details, it gives me command line options (like -fullscreen) but doesn't explain how to use ...
0
votes
2answers
168 views

Using a local HTML file too trigger a bash script execution

While this question seems like its asking for code, its not; exactly, which is why its here instead of SO. I'm designing a RPG game in bash, a lot of things that an RPG game would need, fixed ...
0
votes
2answers
181 views

How can I filter the output from a multicast ping6 to all nodes to get all reachable IPv6 Devices in one moment in time?

How can I filter the Output from a multicast ping to all nodes so that in the output file every IP appears only once? If a new device joins the network its written to a file with a joining ...
1
vote
3answers
2k views

Shell script bash: Moving file iterate based on month

I have very little knowledge about shell scripts, but unfortunately I have to write one. I want to ask about bash script iteration moving files, I need to move log files sorted by month which will be ...
0
votes
1answer
79 views

udev rule not working

I am trying to write a udev rule for USB drive plugin. I want to first mount it to /media and then run the script at /usr/local/bin/script.sh. When I insert the USB, it doesn't even mount the device ...
0
votes
2answers
189 views

Bash script won't exit on ctrl d

I'm writing a simple bash script, and as per my assignment specifications, it is to terminate on ctrl-d. However, it doesn't do that, it just stops reading the current input and begins reading the ...
1
vote
1answer
170 views

Why does my zsh prompt wander upwards when window is too narrow?

I have a weird behaviour that seems to be a combination of zsh and maybe urxvt (?) My setup is this: I start urxvt -e 'tmux' to get myself a terminal which launches zsh as the default shell. I then ...
0
votes
1answer
38 views

Is it possible to connect to the local Windows shell with PuTTY?

I don't know of a working Windows SSH server (not one that I trust enough, yet, at any rate). Therefore, I can't simply connect to localhost on port 22 from PuTTY. I want to use PuTTY because the ...