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

learn more… | top users | synonyms

0
votes
0answers
10 views

How to daemonize a bash script only if --daemon flag is given?

I have my script.sh and want to run it with ./script.sh or ./script.sh --daemon, having it remain in the foreground unless the --daemon flag is given, in which case it should detach and go into the ...
0
votes
1answer
11 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
10 views

How to include a call to ncat to a bash script?

I need to flush a memcached instance from a bash script, I found the following command which do the job: echo 'flush_all' | ncat localhost 11211 But my problem is that the script doesn't continue ...
0
votes
2answers
20 views

sh -c in background

Original version: How to run sudo sh -c "command" in back ground In a terminal sudo sh -c "command" & starts in background but as soon as I press enter, the process exits [test@localhost ...
0
votes
0answers
33 views

How can I delete the content between two tags in a large xml file (>2GB)

The File in Question is XML but I want a Shell Script to remove all the binary (Base64) encoded images that are embedded. The files are generally huge (>2GB). I want to delete everything between: ...
0
votes
0answers
14 views

Mac terminal lost git knowledge

When I opened terminal and went to a git repo, it would automatically show the branch I'm on with a big green check or red X if I had any changes. Logged onto machine today and my bash profile was ...
0
votes
0answers
6 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
3answers
42 views

du -sh : I don't get why these two results are different

I need to know the size of a folder and some of its sub folders. So I'm trying to use the du command. I cd into the right directory and then try (in bash) : [xxx@yyy TEST]$ du -sh . 4.1G . ...
1
vote
1answer
34 views

Bind a key to newline in Bash, without submitting command

I want to press M-j and have readline place my cursor on the next line without entering a command. Thus I should be able to go back a character onto the prev. line. This answer states that it cannot ...
-1
votes
1answer
26 views

bash script doesn't work unless bad command given

I have a script that doesn't work (it freezes my status line) until it is completely done. However, by adding a random bad command, e.g. asdfasdf anywhere in the file that the script reaches (i.e. ...
0
votes
2answers
15 views

list file and using awk to get comment

I want to get the all comment of all files in a folder. And what I have tried is ls -R | awk '/<!--/,/-->/' >> result But it shows nothing in the result file. But if I use the awk ...
0
votes
1answer
16 views

How to create a command shortcut in BASH or ZSHRC shells?

I know how to create an alias or a PATH however those are both used to navigate folders. How would you create a shortcut to say quickly type the following commands every time? alog = tail -f ...
0
votes
2answers
20 views

Bash command for replacing all non-printable characters?

I have a bash script that checks database for changes and emails me these changes. Works nice, until it tries to send something non-printable, which 'breaks' the mail. Is there any handy way how to ...
0
votes
0answers
22 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
0answers
12 views

SSH remote chroot without root

I have a dual boot system consisting of two Debian OSes. I've installed one of them in a root of the partition and installed the other Debian using debootstrap; the installation partition is called ...
0
votes
1answer
24 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
0answers
9 views

openssl print numeric value of the key?

Given a file contains the public key, I need to get the numeric value of the modulus and the e. But I can only get something like this: $ openssl rsa -in key -pubin -text Modulus (2050 bit): ...
2
votes
1answer
43 views

Probing a port for RDP

I use an ssh tunnel to RDP into my home computer ("home"). Occasionally, the tunneling software running on home crashes and the RDP port stops getting tunneled. I've attempted to resolve this by ...
0
votes
1answer
17 views

readline - deleting word under cursor

E.g. Alt-d deletes word until next word boundary. There's also a shortcut to delete until previous word boundary IIRC, but I'd like to delete word UNDER cursor (i.e. to current word left boundary and ...
0
votes
1answer
21 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
3answers
25 views

Is there an automatic way to add group read permissions to “nohup.out” when “nohup” is run?

I run my Java code from bash script using a command like this: exec nohup "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" com.myClass "$@" & Which creates the output file nohup.out and this ...
0
votes
1answer
34 views

bash shell error: “no such file or directory”

I am trying to install Virtualenv wrapper on Ubuntu 14.04. But whenever I start a terminal, I get the error saying bash: /usr/share/virtualenvwrapper/virtualenvwrapper_lazy.sh: No such file or ...
6
votes
7answers
606 views

Remove linux file named with set of shell responsive characters

I've created a file named \;:$"\' to test a software of mine. I ended up with an error because I cannot delete the file property. I'm trying to find a precise char combination to remove via rm, but I ...
1
vote
3answers
23 views

Looping until background process is done (with `jobs`) doesn't work in script

I'm trying to loop until a background process (launched earlier in the script) is complete. An easily reproducible test case is: ping -c 10 localhost &>/dev/null & On the command line, I ...
0
votes
1answer
30 views

No such file or directory when executing an existing file

I have norrowed the error down to this from a larger script and I'm getting the error "No such file or directory" when I try to execute a file which exist and I have the correct permissions for. ...
0
votes
2answers
21 views

Append text to lines between two patterns every time they appear in a file

This will be a rather hard one, i guess. I have to fiddle around with inline documentation that is extracted into html files to be used as online documentation, but these parts of the files should be ...
0
votes
0answers
45 views

Unable to get vmware shared folders working in Ubuntu 14.10 Guest

i Installed Ubuntu 14.10 64Bit in VMWare Workstation 10.0.5 within windows 8.1 Enterprise. I installed vmware tools by running the vmware-install.pl script in terminal.But I am Getting an error ...
0
votes
1answer
18 views

Linux Bash: Moving/Copying files/directories by timestamp

This is the command I am using: find absolute-path -name "*" -amin -120 -exec cp -f absolute-destination {} \; I’m trying to copy a lot of directories from a directory to another directory, but ...
-1
votes
2answers
37 views

Apply command to every line in bash terminal

I've accidentally discovered the lolcat package today. The first thing that I though about is: it would be fantastic if i could pipe everything that comes from stdout to the terminal through lolcat ...
0
votes
1answer
28 views

Remote SSH Commands - bash bind warning: line editing not enabled

I am using bash 4.3.11(1) and have the following history plugin installed (via .bash_it): # enter a few characters and press UpArrow/DownArrow # to search backwards/forwards through the history bind ...
2
votes
1answer
77 views

What is the scope of “exported” in Unix shell variables?

I have set some environment variables in the following way: MY_VAR='helloworld' export MY_VAR Then I have switched to another user via su SOME_OTHER_USER I echo the MY_VAR variable.. and I see ...
0
votes
0answers
18 views

Can’t cd, ls, chown/mod or rm directory — Unknown error: 211 in Mac OS X

Never seen something like this in all my years. This is happening in Mac OS X: $ ls -lO@ea dr-xr-xr-x 2 root wheel - 1B Mar 20 23:10 Music/ $sudo cd Music/ cd:13: unknown error: ...
3
votes
1answer
30 views

What's the best command to discover an application's PID?

Just now, I encountered a bug in Google Chrome. For whatever reason, my Chrome tab, which was open to StackOverflow, created an infinite loop of "Are you sure you want to leave this page?" prompts. ...
0
votes
3answers
72 views

BASH script - execute command in variable

I am doing a bash script to backup my database daily(on Mac OS X) and I want to save the newest 7 backup directories. Here is the problematic fragment of my script(for listing everything but the ...
1
vote
1answer
27 views

How to correct malfunctioning Terminal in Mac OS X?

I am using Mac OS X 10.10.2 (Yosemite)—not a server version of the OS—and standard “Terminal” commands like ls, sudo, cp, mv, rm are no longer recognized in my Mac “Terminal.” I face this problem ...
0
votes
0answers
20 views

how to find packages in subdir with a particular dependency

From the root of new SLES media how is it possible to find all packages with a particular package dependency? That is, there are many RPMs in various sub-directories of root. How may I find all ...
0
votes
3answers
25 views

How do I move files from many child directories into my root directory?

I'm using bash on Mac 10.9.5. I have PDF files in many directories, all one level from the root ... Dir_1/abc.PDF Dir_2/def.PDF Dir_3/ghi.PDF Dir_3/jkl.PDF ... How do I write a shell command to ...
-1
votes
1answer
28 views

for loop in if else conditions in bash [closed]

I'm trying to script the following task. I have a file in which node name and ips are updated, I have to make each file of those nodes which are not in our required directory and those are in updated ...
-1
votes
0answers
10 views

How to remove the source file when converting with LAME via Automator and a shell script?

I have been trying for hours, doing searches on Google, but I can”t find the syntax. I am doing an “Automator” workflow, and I have this code in a Shell script:
1
vote
1answer
23 views

Difference between : and := with variables in bash files

I came across a bash file which has something like this MYVAR := SomeVal I know after reading some tutorials you set values as such MYVAR = SomeVal What is the difference between the above two ? ...
0
votes
1answer
39 views

Non-interactive ssh sessions don't have PATH set on some systems

I set my environment in .profile. My .profile is idempotent and .bash_profile, .bashrc, .kshrc and .zshrc all source .profile. That way I always get the same environment regardless on what ...
2
votes
3answers
46 views

Apparent .bash_profile and .profile conflict in Mac OS X

I have an issue where, when I load up new terminal windows, I have to source the ~/.profile to get my PHP path working correctly. In essence of my issue is getting terminal to use MAMP PHP and MySQL ...
0
votes
1answer
39 views

Download multiple files from ftp server with bash script

I have 2 or 3 FTP Servers where our hoster puts database backups each day. Since he only keeps one, I was orded to write a bash script for downloading alle database backups every day so we have more ...
0
votes
0answers
20 views

static ip address disappeared in the middle of running iperf

The following is done on iperf client side. I set the static ip address for eth0 by modifying /etc/network/interfaces, and activate the change by doing ifup eth0. Then I start iperf -c $server_ip -t ...
0
votes
1answer
26 views

Python debugger not stopping at breakpoints

I'm in a linux based development environment where I don't have superuser permissions. My basic issue is that the breakpoints I set in emacs through pdb never work. The debugger never halts at those ...
0
votes
3answers
75 views

Print previous 20 lines of text from a certain point of a text file

Currently: I'm new to scripting, teaching myself as i go along and this is my first script I'm developing. What my script is trying to do is look at specified file, scan the file to find the word ...
0
votes
1answer
10 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 ...
1
vote
0answers
26 views

Expression within shell script [migrated]

I have just seen this code, but i can't get my head around how this code can actually work. For my understanding it shoud just echo out everything, or am I wrong? deleteOldDumps(){ local SYSTEM="$1" ...
1
vote
0answers
15 views

How to show git branch in Emacs shell

How can I show the current git branch as part of the Emacs shell prompt? For example, I have this in my ~/.bash_profile (I'm on Mac OSX 10.9 Terminal): parse_git_branch() { git branch 2> ...
0
votes
1answer
15 views

zsh completion for all executables in path

I have written a script which itself takes as an argument any arbitrary executable in my $PATH. Is there a way to create a zsh (or bash) completion function such that I would be able to type myFunc ...