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

learn more… | top users | synonyms

1
vote
1answer
1k views

Postgresql query within a bash script

We are having an issue with a postgresql bash query. The output of the query from the bash script add's additional quotes around the date. Please can you help me fix it?! Script: #!/bin/sh ...
1
vote
1answer
415 views

Restore session/state in terminals

When I close my browser it remembers "state" in the sense that it remembers what tabs I have open and text that I had entered into various forms. Is there a way to do something similar with my ...
1
vote
1answer
114 views

How to restore virtual host configuration on Mac OSX

I successfully created some virtual hosts on my machine a while ago by modifying my /etc/hosts file and my http-vhosts.conf file. Then I found a very handy tool called virtualhost.sh (https://github....
1
vote
1answer
236 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 ...
1
vote
1answer
245 views

Bash script fails when putting command into variable

I try to use ghostscript in a bash script on my linux ubuntu 13.04. I have a problem to write ghostscript command in variable when the same command written directly, in console or into a script works ...
1
vote
1answer
357 views

head and cat don't recognize Microsoft Excel text files

I have a large .xls file with 53760 rows and 19 columns. I saved it as Tab Delimited Text in order to pre-process it through command line tools and load it into R later. However, when I run head ...
1
vote
1answer
29 views

Building a String of dynamic length - least consuming way?

I want to write a series of the character -, the amount equaling to 50% of the terminal window column size. I already have the column size. Let's say the terminal column size is 30. My desired end ...
1
vote
1answer
824 views

Mac OSX Mavericks - ZSH can't 'source ~/.zshrc', too many open files

I can't source any changes to my .zshrc (or my .bash_profile for that matter), because I get this error when I try: /Users/ME/.zshrc:source:100: too many open files: /Users/ME/.zshrc I've tried ...
1
vote
1answer
616 views

Can I detect the presence of a second display in a shell script or Conky config?

I want to modify my conky placement depending on whether I'm working with my laptop in my lap (one screen) or have it at my desk attached to a larger monitor (dual display). The problem is that I ...
1
vote
1answer
287 views

Linux timeout if no output

In my script I want to execute a command which connects to a remote server and may take very long time due to a bad network connection. So I want it to time out and be killed after 60 seconds. ...
1
vote
1answer
475 views

Why do I sometimes get 'sh: $'\302\211 … ': command not found' in xterm/sh?

Sometimes when I simply type a valid command like 'find ...', or anything really, I get back the following, which is completely unexpected and confusing (... is command name I type): sh: $'\302\211......
1
vote
1answer
545 views

resizing a terminal within tmux doesn't seem to work

I'm new to tmux, and I'm having trouble finding a solution to resizing my actual terminal (I haven't learned quite enough about panes and windows yet). I'm running tmux1.6, and bash as my shell, on ...
1
vote
1answer
291 views

A screen virtual LED on linux

We have some LEDs on our machine to indicate the status of Caps Lock, Num Lock etc. Now I need a virtual LED in Linux to notify something. For example, I wrote a script to monitor a website. When ...
1
vote
1answer
385 views

How do I get `set show-all-if-ambiguous on` in my .inputrc to play nice with the Python interpreter?

I noticed that after I added the set show-all-if-ambiguous on line to my ~/.inputrc, whenever I pressed tab to indent a block, it would show me the bash Display all ... possibilities? (y or n) prompt, ...
1
vote
1answer
156 views

Recursively move files in sub-dirs to new sub-dirs of same name

I have a batch of files all ending with the same string, ie: *_ext.dat located in several sub-dirs along with several other files, in a given main dir. This is the structure: /main_dir/subdir1/...
1
vote
1answer
883 views

Cannot execute commands in Terminal

My Terminal does not show my username when I open a new window. Additionally, I can't execute any commands either. This is what is in my window: ... Last login: Sat Oct 5 22:27:07 on ttys000 ls -1 ...
1
vote
1answer
109 views

Problems after installing Microsoft Services for UNIX

I had Cygwin installed and everything worked liked a charm. At some point I installed Microsoft Services for UNIX on my computer and the problems started. When I open up a commnad shell an wanna try ...
1
vote
1answer
409 views

xargs in shell script

I want to group jpeg images by odd number and even number. So I did like following: $ mkdir odd $ mkdir even $ find . -regextype posix-egrep -regex ".*[13579].jpg$" -print0 | xargs -i -0 mv {} odd/ $ ...
1
vote
1answer
130 views

Making bash command history act like Windows command shell

In bash, up arrow recalls the previous command. Tap it twenty times, I get the command from twenty places back in history which I ran five minutes ago. Suppose I run that command right now. Now when ...
1
vote
1answer
251 views

Cygwin fatal error unable to configure ssh-host-config

I'm trying to install cygwin on windows XP SP2. After successfully installing, while opening Cygwin terminal it's showing the following error. 1 [main] -bash 4064 C:\cygwin\bin\bash.exe: *** fatal ...
1
vote
1answer
571 views

run a shell script on terminal if terminal is idle for few minutes in linux

i can get terminal idle time by w command as follows $ w 14:37:58 up 2 days, 20:16, 2 users, load average: 0.12, 0.16, 0.14 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT ...
1
vote
1answer
89 views

Show cat output on less exit

After viewing a file in less, with the convenience of scrolling to the side and searching, I want to be able to view/copy the contents of that file normally in my terminal window without having to run ...
1
vote
1answer
2k views

tcpdump output to file not working

I'm trying to write the results of tcpdump to a text file. I am not interested in saving a pcap file to use later, I just need exactly what tcpdump returns in plain text (the ips and timestamps of ...
1
vote
1answer
333 views

launch an automatic action once connected to a specific ssid on OS X

My college requires a local gateway authentication webpage after connecting to their wifi, so I would like to make my macbook pro to automatically run curl with the proper user and password when I ...
1
vote
1answer
77 views

Information flow in Linux - how to tell who is currently active and typing?

I'm currently playing a mafia/werewolves game with my cyber-security class. The basic idea is: on one machine, the moderator starts a server program all the players ssh into the machine and launch ...
1
vote
1answer
587 views

Cron job not abiding by the nice command

I got a script that backs up minecraft worlds, when ran by command (nice -19 ./backup.sh) it doesn't lag what so ever, server load stays low. When I try to do nice -19 ./backup.sh in a cronjob, it ...
1
vote
1answer
184 views

Windows SymLink Questions: How do I tell if a file is symlinked /

I'm not exactely sure how to phrase my questions, I'll describe what I'm doing, perhaps my misconceptions will show. I'm on windows 7. I symlinked files that I'm working on in a project to a sandbox ...
1
vote
1answer
115 views

kill running script (I think I must allocate terminal)

I was wondering how to kill a running script in this situation: Two machines; machine1 and machine2. machine1 writes: ssh machine2 << 'ENDSSH' ./script.sh ENDSSH causing the script to be run on ...
1
vote
1answer
443 views

Auto-mount usb flash drivers for remote servers using bash file for scheduled backup operation

I have to do scheduled backup of servers' databases using a cronjob for the backup task and a bash script for the backup operation. It's a PHP web application. You can choose to store your backup file ...
1
vote
1answer
389 views

How to conditionally send an email in crontab

I am using the following function to find large files (> 40MBytes) for various linux users in my team. It is possible that some of them may not have files larger then 40MBytes. The output of $DUMPFILE ...
1
vote
1answer
141 views

bg command seems not to behave

Could anyone shed some light on this matter ? [root@test1 work]# tsung -f tsung_catalin_filetrans.xml start & [2] 6284 [root@test1 work]# Starting Tsung "Log directory is: /root/.tsung/log/...
1
vote
1answer
338 views

how to remove “downloading” or 0% complete torrents in rtorrent using bash script?

I have 10K torrents and 7K of them are going too slow. I would like to remove them but the rutorrent and rtorrent interface is unusably slow. I noticed that the info about rtorrent is kept in .session ...
1
vote
1answer
386 views

OS X terminal login takes lot of time

From earlier this week my MacBook Pro's terminal is taking a lot of time (about 20 seconds) to see the bash prompt. How do I reduce this time? EDIT: While the login is in progress I tailed the ...
1
vote
1answer
80 views

How to put a Number in to a plist with bash

I'm trying to update my com.apple.background.plist. It works but the "ChangeTime" needs to be a Number/Integer in order to work. I tried to place a -int into the code but it gives an error. ...
1
vote
1answer
1k views

sshpass installation

I want to use passwordless SSH for logging in. I used sshpass to achieve this. The problem is when I am trying to install sshpass through sudo apt-get install sshpass. It asks for password. After I ...
1
vote
1answer
2k views

Pass arguments to osascript via shell function in OS X Mountain Lion

The answer in How to open a new Firefox window with URL argument is broken in Mac OSX Mountain Lion (10.8.2). I can't comment on that answer or question, so I had to create a new question. It fails ...
1
vote
1answer
639 views

“set -xe” in fish shell

In bash, invoking set -x at the beginning of a script causes the commands to be printed on stdout while the script is executing. What's the equivalent syntax for the fish shell?
1
vote
1answer
1k views

How to bind up arrow in ~/.inputrc (readline) for vim insert mode?

When in Readline apps with vim mode enabled in ~/.inputrc (set editing-mode vi) is there a way to bind the <Up> arrow key in vi-insert mode? To display previous history item, for example. It ...
1
vote
1answer
533 views

script for auto adding routing table entries

There are a lot of remote agents that use Mountain Lion. We want only the directories on our intranet to be go through the VPN tunnel and all other traffic to go direct out. So to do this I had to add ...
1
vote
1answer
152 views

change colours when running screen

I use gnome-terminal in Centos 5. I have my terminal settings customized to use the colours I like. However when I run screen (or tmux) the colours for my terminal input lines are always inverted. ...
1
vote
1answer
278 views

using coreutils split file into pieces to different directories?

How can I use GNU's coreutils split command to split a large file into pieces of L number of lines each, but putting each of the different subfiles into different directories at the same time they are ...
1
vote
1answer
151 views

Move group of files into subdirectory

I want to move some ssh keys into a backup file. Specifically, I want to move id_rsa* into key_backups/, a subdirectory of .ssh. mv id_rsa* key_backup/ gives me back usage: mv [-f | -i | -n] [-v] ...
1
vote
1answer
229 views

Is there a shell script that helps identify the non-system related files to backup?

Is there an application or script that will identify all of the distribution/system files? My ultimate goal is: I would like to automate backups to a secondary/alt sec Linux machine, but I would like ...
1
vote
1answer
234 views

cygwin - bash can't find file depending on arguments

If I type bash -i release_script.sh it starts processing the script If I type bash --login -i release_script.sh I get the error: bash: release_script.sh: No such file or directory I don't ...
1
vote
1answer
819 views

How to add bash-completion to user www-data?

when logged in as user 'www-data' on my debian server (squeeze) i want to use bash-completion. I follewed this guide, but i doesn't succeed: it is working for all regular users but not for www-data! ...
1
vote
1answer
500 views

Bind CTRL+W to werase (default bash behaviour in Linux/PuTTY) in iTerm2

I use a Mac at home and have changed my modifier keys swapping Command and CTRL, so CTRL+T spawns a new tab in chrome, CTRL+C is copy and so forth. I use Windows/Linux at work and I want a consistent ...
1
vote
1answer
326 views

Alter bash tab completion to make it more like zsh

I'm on a Mac and the cp and mv commands are killing me due to them copying the contents of a directory if a trailing slash is present. It has bitten me more than once when I use tab completion to ...
1
vote
1answer
695 views

Encrypting using DES 64-bit with openssl

I'm trying to do a very simple thing, namely using a 64-bit password and a 64-bit plaintext (both in hex) and encrypt it with simple old DES. my script looks like this: plaintext=`echo -n "$2" | sed ...
1
vote
1answer
240 views

Sourcing variables from ~/.bash.rc and keeping them across logouts

I've been writing a bunch of bash scripts to make possible non-interactive, secure, cron-based SVN checkouts with CollabNet's SVN client and GNOME Keyring Daemon (aka GKD) and one of the scripts was ...
1
vote
1answer
121 views

Formatting my $PS1 to x amount of character

I'm looking for a way to force my PS1 variable to a certain number of chars. It currently looks like: $PS1="\W $" and I'm trying to keep the same number of characters regardless of the length of ...