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

learn more… | top users | synonyms

4
votes
3answers
1k views

Bash extended globbing inside a Makefile

I want to do an operation on all the files in a particular folder that do not start with a particular prefix (say exclude_). I have a bash for loop with an extended glob that looks like this: for ...
0
votes
0answers
84 views

Getting rid of “bash.exe” - from my startup

Soluto reports that bash.exe is taking up 40 seconds of boot time, but I cannot disable it. If I search for it in msconfig, I cannot identify it. If I search for "bash.exe" I cannot identify it. If I ...
1
vote
2answers
743 views

Execute a script as root on every ssh login

Is there a possible way that I can execute a script, say abc.sh; as root user on every login to my system via SSH? I've gone through a similar question which says to add the script execution to ...
4
votes
1answer
959 views

Get modification time of remote file over HTTP in Bash script

I'm creating a simple Bash script to extract the file modification time/date of a remote file via HTTP. Example file: http://example.com/bar/example.pdf Can this be done without downloading the ...
0
votes
2answers
90 views

How do I parse metacharacters for function input in bash?

I wrote a function in bash which gets * as input and therefore sould list all files in that particualar dircectory. but doesn't. Here is what i wrote: # a function that mass deletes files in a ...
41
votes
2answers
5k views

what is the difference between “command && command” and “command ; command”

I see these two usage on Ubuntu "command && command" and "command ; command", e.g. apt-get update && apt-get upgrade What would differ if I use apt-get update; apt-get upgrade? I ...
0
votes
1answer
92 views

What will * in bash do?

My question is quite simple, if I am to enter these two line in OS X Terminal, what should happen? xupengjunde-iMac:Shane Shane$ cd /Volumes/External xupengjunde-iMac:External Shane$ sudo chmod -RN * ...
1
vote
2answers
63 views

Drawing interactively from the bash history to construct a complete command?

At the bash prompt the command history can be explored using the up and down arrow keys. (I also often use CTRL+R.) Is it possible to do this without replacing the character string to the left of the ...
0
votes
1answer
43 views

Why does 'which' give incorrect result?

I am executing on a Ubuntu 12.04 shell the following command: sudo bash -c "echo $PATH; which python" which displays something like ...
3
votes
2answers
2k views

Terminal blank, .bash_profile broken

I was following a tutorial for configuring OS X Mountain Lion and somehow after editing the bash_profile I can't run the terminal properly. The terminal starts just fine but is blank, if a wait long ...
0
votes
1answer
73 views

Bash script: allow change of “environment/identity”

I came across this problem now several times and I would like to find a way to automate/script this things that involves a change of identity or environment (I am not sure how to call that precisely). ...
1
vote
3answers
3k views

Argument list too long for xargs/exec

I'm working on a CentOS server and I have to move around and cat together millions of files. I've tried many incarnations of something like the below, but all of them fail with an argument list too ...
0
votes
1answer
282 views

ssh: execute privileged command when a non-root user logs in?

I am trying to run a command/script that requires root privileges when a non-root user logs into ssh This unfortunately means I cannot use ~/.bashrc or /etc/bashrc I also tried /etc/ssh/sshrc but ...
1
vote
1answer
1k views

How do I safely kill xscreensaver from a script/the command line?

I'm using a Linux (RHEL6) workstation. I have a small script I wrote which locks and unlocks the screen via xscreensaver when I connect or disconnect my USB thumb drive, which effectively turns it ...
3
votes
1answer
117 views

Is it possible to check which stream is used by the command? (bash)

I have an irritating problem: redirecting stderr does not work. I get: iptables: Chain already exists I can't be bothered to check if a chain exists already (pointless, iptables just throws an ...
1
vote
1answer
358 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
509 views

Remove __MACOSX directory in zip files by using shell

I want to remove __MACOSX directory in zip files that are made by Mac. With zip foo.zip -qd "__MACOSX/*" works well. Then I wrote like following. for file in "*.zip"; do zip $file -qd "__MACOSX/*"; ...
1
vote
2answers
3k views

Spaces in Linux environmental variables?

Given directory: /media/foo/can haz/bar, I have tried editing bash.rc with: export Foo=/media/foo/can haz/bar export Foo=/media/foo/can\ haz/bar export Foo='/media/foo/can haz/bar' export ...
0
votes
1answer
31 views

Executing scripts in terminal

So instead of wanting to navigate to the location of a script and run ./script.sh, I would like to be able to type "script" from anywhere and have that run. I think this can be done by putting the ...
2
votes
2answers
547 views

Create zip files that with given size

My question is same as in Create multiple zip files that are not dependent on each other? but my idea is to add files to zip until it is of required size and continue with a new zip file for others ...
1
vote
2answers
400 views

OS X Terminal - Find Text in Files Beginning With Variable

I need to search through a folder of files and copy all text that begins with a variable. So for example: Files A.txt,B.txt,C.txt, and D.txt contain the strings "Hello1", "Hello2", "Hello3", and ...
-1
votes
1answer
297 views

while loop in bash until file size does not change [closed]

I'm trying to do the following while loop using a bash script file_size = 0 temp_size = 1 output_file while (file_size != temp_size) temp_size = file_size download file append to ...
0
votes
2answers
441 views

redirect output from rpm -Uvh postgresql91-*.rpm

I have a bash script to install postgresql part of the script contains this command rpm -Uvh postgresql91-*.rpm i need to direct ALL the output generated by this rpm command into a log file FROM ...
18
votes
3answers
2k views

Why does the output of some Linux programs go to neither STDOUT nor STDERR?

Why does the output of some Linux programs go to neither STDOUT nor STDERR? Actually, I want to know how to reliably capture all program output, no matter what 'stream' it uses. The problem I have is ...
-1
votes
1answer
209 views

When I extract a tar file, all the files/folders have 777 permissions

I run Debian. I have a tar archive that, when extracted, assigns 777 permissions to all files/folders in it. I believe this has to do with the fact that I'm root, but is there a way to make it so they ...
3
votes
1answer
563 views

screen - move cursor to beginning of line

In bash I can usually move the cursor to the beginning of the line using CTRL+a. In screen, CTRL+a is being used for the special screen-commands. How can I a) use another key-combination for the ...
0
votes
1answer
406 views

How can I both use and modify the history inside a bash script?

So I have the following bash script aliased as "fortunes": #!/bin/bash -i REPLY=; history -w /tmp/fortunes_history_backup; # save history ... history -c; # and clear it. while [ ! \( "$REPLY" = "q" ...
11
votes
3answers
20k views

Finding files which contain a certain string using find (1) and grep (1)

find . -type f -print -exec cat {} \; | grep some string Command above doesn't print the file path. I'm using: Ubuntu, bash 4.
2
votes
3answers
319 views

Shell script not running as by “./” but it runs by “sh”

I am running a script on arm target board as a super user, i.e., as a root user. But the script is not executing if i run it with following syntax root@freescale$ ./Script.sh -sh: ./Script.sh: ...
0
votes
2answers
420 views

SSH commands with bash

I have a list of servers in a .txt file. Assume that the authorized keys are all in place in the servers. #!/bin/bash while read server <&3; do #read server names into loop [[ $server =~ ...
1
vote
3answers
124 views

Use latest version of package in bash script

The installed package libnet-amazon-ec2-perl uses v0.14.1. How do I update this package to use the latest stable release v0.22.1? When I try sudo apt-get --only-upgrade install ...
0
votes
1answer
119 views

Cygwin Syntax Trouble

I'm on windows 7 using Cygwin. My script and text file are located in the same directory. #!/bin/bash while read name; do echo "Name read from file - $name" done < /home/Matt/servers.txt I get ...
1
vote
3answers
313 views

Line by line not working

Script FILE="/u0146121/bin/list.txt" while read line; do echo $line done < $FILE I am new to bash scripting and trying to figure out this while loop. I want to read line by line from a text ...
1
vote
1answer
181 views

Red5 on Debian, output PID

I'm fumbling my way through with this one, as a novice with all things linux so please be patient :) I would like to output the process ID of a program to a file. From my readings this is generally ...
2
votes
1answer
110 views

Cannot type a letter while in Bash in Cygwin

I am unable to type a certain letter while in bash. I was editing .bashrc, or possibly .profile, which made it impossible to press the letter "a" (it is not showing up on screen, although I am able ...
2
votes
3answers
534 views

log execution of certain commands on linux

I have to maintain a system (debian) on which several users are allowed to install programs - so I would like to log, for example, if anyone executes "apt-get install" or "apt-get purge", so I can ...
4
votes
1answer
279 views

Bash: color prompt and command differently from output stream

I'd like to color the prompt and command of my shell differently from the text printed in the output stream. My current export for PS1 is as follows: export PS1="\e[0;36m\h:\e[m ...
0
votes
4answers
2k views

How do you pass a file or folder containing whitespace as an argument to a command-line program in a GNU/Linux or Cygwin environment?

There are occasions when you are working with files and folders that contain spaces in them. The problem is any time you try and pipe files / folders containing whitespace to another command-line ...
-2
votes
2answers
104 views

Looping and reading by line in Bash [closed]

Read a file of server names (.txt) line by line loop through each server name and connect by ssh Any suggestions, comments, and ideas?
2
votes
2answers
252 views

Is it possible to have App-distinct Color Scheme in ConEmu?

I am presently using Bash (with Cygwin), as well as Powershell, both using ConEmu. I'm using bash.exe and powershell.exe via tasks. I'd like to use different colour schemes for the different ...
1
vote
0answers
276 views

ssh Prompts For Password After Account Unlocked - Despite ssh key?

Here's what happened: I set up ssh key so that user could ssh from A to B without a password. I got user's password wrong in some other context too many times, and user's account got locked out. ...
-1
votes
1answer
2k views

find: ‘ls’ terminated by signal 13 error [duplicate]

My Script log=$HOME/Deleted/$(date) find $HOME/OldLogFiles/ -type f -mtime -7 -exec ls -latr {} \; -exec echo was deleted on `date` \; -exec rm -f "{}" \;|paste - - >> $log My goal for the ...
1
vote
1answer
264 views

Clean logging with BASH

I have a script that deletes files 7 days or older and then logs them to a folder. It logs and deletes everything correctly but when I open up the log file for viewing, its very sloppy. ...
1
vote
2answers
761 views

Accidentally copied files over /bin/bash in OS X

I mistakenly copied two files over /bin/bash. This now made my terminal non-responsive. I've followed this tutorial but it didn't help. For reference, the files are runcocoa.sh and runc.sh to be ...
1
vote
3answers
166 views

How to create a series of commands in shell, which will stop execution on error

My usual git workflow for deploying is the following: [while on master branch] git pull git push git checkout production git pull git merge master git push Would it be possible to create a ...
0
votes
1answer
170 views

In Bash, how do I pass the output of the first command to a command line argument of the second?

For example: mycommand.py -a `cat myfile.json` In this example, I need the contents of myfile.json to be passed as the value to the -a argument of mycommand.py. This almost works, but I need the ...
3
votes
3answers
2k views

PuTTY not sending Esc

I SSH with PuTTY from my Win7 x64 laptop to a Unix environment for my office. The problem I'm facing is very similar to this post where I cannot send an Esc character to the terminal. I first noticed ...
2
votes
3answers
138 views

I used mv ./*/* to flatten a directory on a ntfs filesystem, without add . to the end of the command, now all of my files are gone

How can I recover these files? I used: mv ./*/* when it was supposed to be mv ./*/* . Now all of my files are gone.
1
vote
0answers
71 views

Bash Shell doesn't recognize the letter “t”

I have Cygwin running on a Windows 7 Box. In what is a relatively new (and strange) development, the bash shell stopped recognizing the lowercase "t". For example: I type echo cat, output is ...
5
votes
2answers
16k views

Cygwin Dos2Unix Command not found

I am having some problems using cygwin. I am trying to use the dos2unix utility and cygwin is throwing -bash: dos2unix: command not found When I go back into the installer and look through the ...