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

learn more… | top users | synonyms

1
vote
1answer
28 views

for loop (f in *.txt) throws error if no *.txt file exists

I have a small bash script which looks something like this: #!/bin/sh for f in ./*.txt do f=$(basename $f) echo "Processing $f" scp somewhere mv $f done/`basename $f` done This is working ...
1
vote
3answers
90 views

How to Copy all the .c files starting with letter [h-o] to directory h-oFiles

I'm trying to accomplish this one command and this is what I tried: sudo cp /hw2/ladsrc/.c[a-g] /hw2/a-gFiles What am I doing wrong here?
0
votes
0answers
25 views

source ~/.bashrc No command 'some' found, did you mean:

I just recently installed ubuntu 14.0.4 and I'm not sure why I can't source my ~/.bashrc. Whenever I issue source ~/.bashrc I get: No command 'some' found, did you mean: Command 'tome' from ...
3
votes
2answers
33 views

How to echo multiple lines?

I have such lines: server { listen 80; server_name $brand.mydomain.com; root /srv/www/clients/$brand/soon; } How could I append all those lines at once to the end of ...
1
vote
2answers
35 views

What is the maximum value of a numeric bash shell variable?

I'm curious as to what happens when a numeric variable in bash is incremented up without purposely stopping it. How large can the number get? Will it overflow and become negative and just continue to ...
1
vote
3answers
28 views

Show which command failed

command1 && command2 && echo "OK" || echo "FAIL" This will print OK if both commands succeeded or FAIL if either of commands failed. How can I modify this to print: OK if both ...
0
votes
1answer
22 views

Vagrant SSH & Nano on Linux Mint 17.3

I've recently installed Vagrant (1.7.4) and VirtualBox (5.0) on 3 laptops each running Linux Mint. Have reached a stage on all 3 where I need to edit a config file on the VM itself. So far, so good. ...
0
votes
0answers
16 views

Launch agent to run a .sh when it is added to a folder

I am trying to create a launch agent that will monitor a folder for when a .sh file has been added to it and run that .sh <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC ...
0
votes
0answers
15 views

Increase efficiency of bash loop with awk

I have to write a fairly large text file(>300,000 lines) using text extracted from the second column of one file, then prepending and appending text to each line and finally writing it out to a new ...
0
votes
0answers
23 views

Git Bash delayed output

I run some program in git bash terminal on windows and redirect output to grep to search for specific keywords. Problem is that the output is delayed, so it looks like the terminal waits for a chunk ...
1
vote
1answer
25 views

How to prevent “source” in a bash script from passing the script's arguments?

These questions address the functionality of source: What is the difference between executing a bash script and sourcing a bash script? What does 'source' do? but I'm confused as to why ...
0
votes
1answer
14 views

sudo ssh-add /root/.ssh/id_rsa return error

I m trying to save ssh authentication with the command ssh-add for sudo usage: linux$ sudo ssh-add /root/.ssh/id_rsa Could not open a connection to your authentication agent. but as indicated it ...
3
votes
1answer
51 views

Install command-line tools in Mac OS X El Captain using bash

I am trying to install command-line tools in Mac OS X El Captain using bash. xcode-select --install Running the above command pops up a window and asks the user to select install. How can I ...
3
votes
1answer
49 views

Why ctrl+c in console kills the background process

Could you explain why Ctrl+C in my bash shell affects the command that was run previously in background with: `./my_script.sh 1` & The command immediately finishes the execution with 130 code: ...
1
vote
1answer
14 views

Sort files by date and copy every other to new folder

I was wondering what would be the most concise way of sorting files by date and then copying every other to a new folder. My problem: I've got files renamed such that they are called file1 (101) ...
0
votes
1answer
27 views

Needing to open OS X bash script as via launchd IN a terminal window

I've got a lengthy and complex bash script which works OK, but I'm trying to automate my deployment process and I'm flummoxed at this point. I can get the script to run as a LaunchAgent no problem, ...
0
votes
2answers
34 views

How to perform batch commands in terminal for files in each folder

I have a folder which contains some folders inside. In each folder there are some bmp files. I want to go inside each directory, convert bmp images to pgm format and remove original bmp files, and ...
1
vote
2answers
42 views

Using Sed Ampersand Substitution with Array

I am trying to use the ampersand character of sed to replace with the original string, and then read from the array, but it is not working. I just get the error: 'operand expected (error token is ...
0
votes
1answer
11 views

is it possible to filter the content of .xsession-errors?

Most users .xsession-errors file grows because gtk and other librarys give silly error messages. Is there a way to reduce silly error messages but have a usefull .xsession-errors file?
0
votes
1answer
42 views

Behavior of same commands (under Bash) - running one by one in console vs as single script

Running on OS X 10.11.1, I execute the following series of commands (one by one), in the console: FILE="a b c.tiff" # file in the current folder VAR=$(mdls -name kMDItemContentCreationDate $FILE) # ...
0
votes
1answer
74 views

Docker on Conemu

I am trying to make docker run on ConEmu by creating a task that open up Docker start.sh file usinggit bash. Since normally docker Terminal is pointing to "C:\Program Files\Git\bin\bash.exe" --login ...
-1
votes
2answers
20 views

Why do I fail to `diff` over `ssh`?

Problem Following this post I tried to use diff over ssh using bash process substitution diff foo <(ssh myServer 'cat foo') When I enter the following command diff ...
0
votes
1answer
8 views

Bash Export Syntax Compatibility

I often see commands written with the following syntax and I am curious if this is done for compatibility reasons: Snippet from Default .bash_profile on CentOS # User specific environment and ...
0
votes
0answers
10 views

Checking if file exists to launch different programs

I use the following code to check for a file named loaded in the shared folder.This works when the file is placed in the local dir but it does not write the file to the shared folder. What I'm i doing ...
0
votes
0answers
12 views

mac terminal and iterm does queue up input during operations

I have this problem where if I input something time consuming the inputs I give the terminal does not queue up on the next command line. $ rails c afsdfadfadsfadfa development environment (Rails ...
0
votes
1answer
33 views

redirect ALL output from shell to a command to act as filter

How to redirect all std-output from bash to a command like 'grep' or 'sed' to filter the output and then write it to a file? This is what I want in principle: exec > >(cat | cat ...
0
votes
0answers
33 views

Make `last` display year in Terminal

Is there any way to get last (on Mac OS X 10.11.2) to display a full date (including year)? Right now it displays only day and time: user$ sudo last user | head -n3 user ttys000 ...
1
vote
1answer
21 views

Prevent open -a Terminal.app from automatically exiting on Mac OS X

On my Mac OSX 10.9 Mavericks, I wrote a small bash script to open a log file for a terminal game application I'm writing so I can see print statements: #!/bin/bash printf '\e[3;0;0t' ...
0
votes
0answers
34 views

stty: standard input: Invalid argument error when scping files

When I try to scp a file to my remote server I get the following error: stty: standard input: Invalid argument This is caused by a line in my .bashrc file: stty -ixon If I remove that line, the ...
0
votes
1answer
33 views

How can I send email with attachment xls file using shell script as application/xls mimetype without making the received file becoming unreadable

#!/bin/bash ATTACH1=file.xls<br> SUBJECT="subj"<br> FROM=me@domain.com<br> TO=you@domain.com<br> CC=them@domain.com<br> MIME="Application/vnd.ms-excel" <br> ...
1
vote
1answer
69 views

The “shmmax” value is too large when installing Oracle 11g on RHEL7

I am trying to install Oracle Database 11g Release 2 on RHEL 7.2. Executing runfixup.sh, it outputs: # /tmp/CVU_11.2.0.1.0_oracle/runfixup.sh Response file being used is ...
2
votes
0answers
17 views

In Ubuntu use GTK file save dialog from bash command line?

I would like to do something like gtk-file-saver /tmp/tempfile.txt And then a GTK file saver pops up for the user. By this I mean the normal dialog that is used whenever you do "Save As" in most ...
0
votes
2answers
47 views

XML query in Bash with XMLStarlet

I need to extract a few values from an XML file, and I stumbled onto XMLStarlet that seems pretty powerful. Knowing little about XML, I'm overwhelmed with the tool, and likely need only a very tiny ...
1
vote
3answers
43 views

sed command in console works; but in shell script it throws error

I am trying to write a shell script to replace the SEARCH string by REPLACE string in all the files of the current directory (directory where my script remains). The condition I have is : the script ...
0
votes
1answer
21 views

PID of commands run as different user

While being a root, I want to start a service as a specific user and write its PID file. Minimal nonworking example: if [ $UID -eq 0 ]; then su myuser <<EOF sleep 30 & echo $! ...
0
votes
1answer
27 views

Debugging env vars from ssh

I'm writing a script and an application for an embedded board with linux - no X, only console. The only way to reach the target is via ssh, I don't have a monitor connected. The script should export ...
0
votes
2answers
20 views

bash for loop in parallel with n cores

I have a bash loop that looks like: for i in $(seq 0 $max); do my_command $i done and I would like to run this in parallel on n cores. I know that I could do while [[ "$j" -le "$max" ]]; do ...
0
votes
0answers
24 views

Linux hangs after rebooting

I have a script that needs to run at boot time, I set it up using update-rc.d and now when I reboot the system with sudo reboot the system hangs during the boot process. But if I restart the system ...
1
vote
2answers
45 views

how to make ls show hidden files then directories then regular files in order

Is there a way to get ls to show all dot files including hidden directories first then regular directories then regular files? I have read throughout the ls man page but come up with nothing. I have ...
0
votes
1answer
23 views

Pipe arguments into “open” command

I'm trying to open a large list of .xml files using the following command: ls | grep navigation-drawer-config- | open However, this doesn't work. From my understanding of piping, this should pipe ...
0
votes
1answer
17 views

echo does not apply a line to crontab

Want to apply this to crontab: crontab -l > nopass echo 'ALERT - Found a user without password on:' `hostname` `date` | cat /etc/shadow | awk -F: '($2==""){print $1}' | mail -s "Alert: Found a ...
0
votes
0answers
15 views

How to add .bash_profile in Windows to run Matlab-based IPython notebooks

I'm looking at this tutorial to run matlab code in IPython notebook: http://anneurai.net/2015/11/12/matlab-based-ipython-notebooks/. but I am stuck at step3: I edited the .bash_profile file located ...
0
votes
2answers
15 views

How to join files using 'tail' command while displaying limited lines

I have multiple log files and I want to display its joint output. One way of doing this is by executing this command: tail file-1 file-2 But I also want to display only a specific number of lines ...
0
votes
1answer
28 views

Bash Permission Denied on all files in my ssh

I just logged into my linux ssh that I had been using all last year for the first time since Holiday break and I am trying to view my files with less file and head file but I am getting Permission ...
3
votes
1answer
24 views

Pass arguments from script to PHP interpreter is not working with quotes, why?

I need to create a wrapper script for PHP interpreter (already in PATH): #!/bin/bash # This is a wrapper for the PHP interpreter. # # We prepare the enviroment for SQL Anywhere PHP extension sourcing ...
1
vote
1answer
41 views

how to “trace” a program such as shell?

I understand that dash is a "model" shell - it was written recently and well and it only implements what is required of POSIX shell. I looked at the dash source code to understand how "tracing" of a ...
0
votes
3answers
37 views

How to run a bash script at boot-time

I know this question has been asked several times but I simply can not get it to work. Here are the steps I have taken to get it working: wrote script saved as collection.sh moved collection.sh to ...
0
votes
1answer
32 views

How to get HTML file as a content to mail (shell script)

I am new to shell script, I have an HTML file which contains table data. Now I need to send this file to mail. mail -s "test" abc.com <test.html Currently I am getting the raw HTML code for the ...
0
votes
1answer
23 views

Use grep to NOT see files matching a pattern?

I'm very familiar with using grep with the pipe to exclude everything that doesn't match a pattern. But can I use grep to exclude everything that DOES match a pattern? I thought this would work, the ...
1
vote
0answers
22 views

How can I configure git bash to display a timestamp for each command?

I run git's bash on Windows7 to manage source control for projects. Can I edit C:\Program Files (x86)\Git\etc\git-prompt.sh to enable me to timestamp when I ran commands? e.g. instead of ...