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

learn more… | top users | synonyms

2
votes
1answer
35 views

How to include hidden files in ls pattern match?

I was just trying to list files in the current directory with a certain pattern, but it doesn't work with hidden files. How can I match all the files? I tried ls *foo* and ls -a *foo* Not ...
2
votes
3answers
46 views

Linux mv command for moving multiple files with different extensions

I am wondering if it possible to use bash to mv multiple files with different extensions into one directory, for example mv 1.png 2.jpg dir/ except match many files
0
votes
0answers
16 views

Location of commands executed in past

With HISTTIMEFORMAT="%d/%m/%y %T ", history command shows the exact time of the execution of a command. Is there a way to find from which folder the command was executed?
0
votes
1answer
24 views

Clearing global history in PuTTY

I was wonder how Putty stores history. I have server and multiple account there. Every account has a history when I use "history" it lists the history from that account. Is there something like global ...
0
votes
0answers
10 views

exclude files when uploading via ncftp / ncftpput

i found a well working solution for my server setup thanks to this Question: Syncronizing files over FTP Now I have only NcFTP available on my Webserver http://ncftp.com/ncftp/doc/ncftpput.html and ...
1
vote
1answer
28 views

Reverse output of a command

I'm trying to get the reversed output from git log --branches --graph --oneline (Sadly you can't pass --reverse to it because it says it's incompatible with --graph) Is there a way to reverse the ...
0
votes
0answers
27 views

SSH .bashrc Alias for `Clear` Command Twice

Sometimes it is helpful to call clear twice to add some padding so that scrolling up or down will allow us to look at the output of previous commands easier, e.g. I can segregate compiler output by ...
1
vote
1answer
37 views

How could I overwrite file hosts in OS X?

Well, in my company I have to change file hosts to map the domain to the LAN IP because our servers located here. Then when I arrive to home, I have to change hosts file again to comment out which IP ...
0
votes
0answers
20 views

If screen's C-a A command does not work, what internal state must be wrong?

In the Linux command screen, you can type C-a A to change the name of a window. Right now I am running a screen session with six windows. The first four have custom names - great. The last two I want ...
1
vote
1answer
28 views

Using cURL command-line tool on Mac, What can I do to this script to ask it to fetch stock data which will replace commas with NO SPACES

Example: Google Outstanding Shares are 670,000,000 and this value is collected in a txt file from Yahoo Finance API via the below script. The issue is; that numbers WITH commas or spaces are a bloody ...
0
votes
1answer
37 views

while loop condition - search for string pattern in bash

I am altering a bash script and I need to write a loop and test if file of a specific pattern exists in source directory. Script works if I designate a specific file but not with a wild card ...
0
votes
0answers
19 views

Piped processes in upstart shell script continue running after stopping

I have an upstart script on my CentOS box that runs a shell script. The shell script runs a netcat command whose output is piped through a couple other commands and then ends up in a file. When I ...
28
votes
10answers
3k views

Prevent user typing accidental space between rm and wildcard

Intention: rm -rf string* Problem: rm -rf string * The first case is a legitimate and common use of rm, a small typo can cause a lot of problems in the second case. Is there a simple way to ...
2
votes
1answer
14 views

Use argument of unrun command in Linux

If I wanted to run mv arg1 $(sed arg1 's/regex/replace/') is there a better way to to do it than to reinsert the filename into the sed command?
1
vote
1answer
61 views

Using the with cURL command-line tool on Mac, What can I do to this script to ask it to fetch stock data which comes back WITHOUT commas?

cd documents/quoteUpdate while true do curl -o quotes.txt -s "http://download.finance.yahoo.com/d/quotes.csv?s=goog,aapl&f=sl1c1p2pt1" echo UPDATED: date sleep 10 done
-1
votes
1answer
41 views

Exclude folders with a path pattern using FIND command on Ubuntu console

PROJECTS |___ SITE1 | |____files (to exclude) | |____img | |____js | |___ SITE2 | |____files (to exclude) | |____img | |____js | |___ ...
0
votes
2answers
24 views

How can I determine the IP of a remote host in a shell script?

I have an IP alias that switches between two hosts depending on the host's availability. (This is a very large network and the switch is done externally of local control.) I need to determine when ...
0
votes
1answer
74 views

windows 7 file explorer crashes after mkdir via git bash

My environment: Windows 7 Git v1.9.0 Steps to reproduce my problem: open a folder in windows explorer right click in that folder and select "Git Bash" execute: "mkdir test" in the git bash ...
0
votes
1answer
34 views

console command result as input file for sed or other commands

Some commands take a file as an input, is there a way to treat a result of a command as a file? for example I want to get a string between 2 strings: sed -n "/START-WORD-HERE/,/END-WORD-HERE/p" ...
0
votes
1answer
25 views

Run script under OSX _www user account

I have a small internal for my use only php website which triggers a bash script to do some app signing etc. I need that bash script to run some ruby gems. (Security is not important.) The way I see ...
0
votes
2answers
41 views

Tmux - Execute command in session on startup

What I want to do is really simple, but I can't seem to find a straightforward answer. I found this question and this question, but they're not quite what I need - I'm not running multiple sessions ...
1
vote
2answers
27 views

Disown / background a command passed into bash

TL;DR at the bottom. I am trying to make a simple lock screen for my laptop running Arch / BSPWM. I found a program called cmatrix which has a screensaver flag that causes it to exit when a key is ...
0
votes
1answer
22 views

terminal previous history command overwrite characters

I have a weird behavior in my terminal (bash). When I CTRL-P, then try to insert some text at some position, the following characters overwritten. Not really overwritten but my terminal dont show ...
0
votes
1answer
13 views

Length of range in bash [duplicate]

I'm trying to delete some files in a directory using some commands. Using loop for i in $(ls -tr $path); ... i need to know length of $(ls -tr $path) How to get the number of files in directory $path ...
1
vote
1answer
21 views

Terminal/Bash session manager

Is there a session manager for multi-tabs bash sessions, similar to how Google Chrome manages web surfing sessions? What I'm looking for is the ability to store and restore the shell tabs (I'm ...
0
votes
1answer
33 views

How to rename files to monotonically incrementing sequence numbers followed by a suffix?

I want to rename all files under a particular directory to a number followed by a suffix. For example, I want to rename all *.jpg files to 1.jpg, 2.jpg, 3.jpg, ... I thought about using find for this ...
0
votes
0answers
13 views

Proud to have succeeded in renaming a file starting with “??” [duplicate]

I was using the shell terminal to rename and move files. I am rather not an expert. I made a mistake (I believe, using ctrl-v instead of cmd-v to paste a piece of text into the bash line, set a wrong ...
0
votes
1answer
32 views

Piped awk command works as one-liner but not in loop

I have a part of a script that isn't working as expected. It's supposed to take a list of newline-delimited episode paths in the format "/volume1/Shared Files/Cartoon/Show Name/Show Name SXX/file.mkv" ...
-1
votes
1answer
16 views

I am trying to embed a patch in a bash script - can't get patch to read the patch from a variable

read -d '' PATCH_OS <<EOF //PATCH//TEXT// EOF patch -b < ${PATCH_OS} This fails: ./script.sh: line 39: --- //PATCH//TEXT// (line 39 is "patch -b < ${PATCH_OS}"")
0
votes
1answer
25 views

Add character to end of nth line in terminal

I'm trying to add a number of spaces to the end of the N:th line of a file from the command line. Can anyone show me how to do that?
0
votes
2answers
34 views

How to run a command in a new gnome-terminal?

I want to run some commands on some servers. So, I created a bash file: #!/bin/sh for n in `cat ~/nodes`; do gnome-terminal -x ssh root@$n ANYCOMMAND done The connections are ...
0
votes
1answer
24 views

Bash script failure

I have this script. It works fine on one of system but it's giving some error on another machine: 1 #!/bin/bash 2 EXEC_DIR=`dirname ${0}` 3 source ${EXEC_DIR}/config.sh 4 5 ...
0
votes
0answers
15 views

programmatically configuring osx loginwindow

I wonder if one can devise a tool for system administrators to programmatically configure that the login window doesn't show user accounts' full names, but short names instead? This used to be ...
0
votes
2answers
19 views

Using “for in” to iterates files but except specified one(s) in shell

I found a post here How can I run mogrify, but prefix the filename? which is talking about resizing a batch of images. In it there's a for in shell script. How do I except some single file(s) while ...
0
votes
2answers
24 views

How can I pass the result set of filenames from an MySQL query to zip in Linux

My problem is pretty straight foward, and I think I'm close but need a boost in the right direction. I have a MySQL table that contains a lot of file names that are used by a website. These files all ...
0
votes
1answer
25 views

Bash last command - skip identical commands in history

By using the arrow keys one can fill the command line with the last called commands. However, Bash does call all the previous commands, not just unique commands. $./a.out //oldest command ...
2
votes
1answer
33 views

How to set up an ssh server ON OS X

I'm planning on making a bash script that sets up an SSH server. The script is only meant to work on a computer running OS X. With the research I have conducted it seems like you have to use the GUI ...
0
votes
1answer
19 views

Change R BLAS library path

Currently the R on my system using this library for `BLAS': ldd /usr/lib/R/bin/exec/R libblas.so.3gf => /usr/lib/libblas.so.3gf I want to change the path to use ACML. Is it possible to change ...
0
votes
0answers
25 views

Highlight bash output in iTerm 2?

I've followed the instructions for installing Solarized on iTerm 2, on my new OSX Yosemite machine. It looks as though the background and basic colours are being applied, and $TERM produces ...
4
votes
1answer
174 views

Find and delete folder but not content

I'm trying to find all folders named b and delete them, without deleting their content (whether folders, files, hidden files, ...). So for example, a file in a path /a/b/c/file should become ...
9
votes
4answers
577 views

Is it possible to print out the shell expansion?

I know there is a specific set of rules that shell expand the commands user typed. (let's talk about bash shell.) Is it possible to print out a command in the form after shell expansion? It seems to ...
0
votes
1answer
25 views

Is it possible to 'source' the output of a python script

I have a large python codebase that knows a lot about my working environment. I would like to use it to set up my ZSH session when i open a terminal window. The python script would output text that ...
0
votes
3answers
50 views

What's the Bash equivalent of “cmd /c”

I'm trying to launch a Bash Shell window that should immediately start a Windows Application. It's the Bash Equivalent of "cmd /c MyApplication.exe". MyApplication is a Windows Console application. I ...
0
votes
0answers
48 views

Unable to run script, which emails me results, as super user. (returns: send-mail: 550 5.1.0 Not our Customer)

I have been trying to debug this for 2 days now, without success. This is the script I'm trying to run: #!/bin/bash emailaddress='my_username@gmail.com' output=`sudo rsync -av --delete ...
0
votes
0answers
20 views

Theme problems with vim and terminal

everyone. Trying to figure out a weird problem I'm having with VIM, that's probably just me being a complete novice with the program. I started using it today, and was told to use Vundle to manage ...
0
votes
2answers
32 views

Counting the number of open files for each user?

I am looking for a command that would list me number of open files for each user, sorted descending. For example lsof -u postgres | wc - would list them only for the postgres user, but I do want to ...
1
vote
1answer
38 views

Bash loop through all directories within a directory and if find any instance of string in each directories specific file do this

I have a service that utilizes a unique user specified port for remote connections. I install multiple instances of this service and wrote a bash script to automate the installs. My installer has a ...
2
votes
1answer
36 views

How to write a function that writes both to console and log file?

I'd like to write a function that writes a message both to console and log file. My initial attempt was this one: function log_write { local message=$1 local log_file=$2 echo "${message}" ...
0
votes
0answers
16 views

How to make an application accessible for ISPConfig's shell user?

We are using ISPConfig to manage our VPS. We have created a domain with a shell user assigned to that domain. There is an application installed on the VPS that is called drush (shell application for ...
0
votes
0answers
22 views

PHP - Exec on user's GUI session

I am trying to get a PHP script to execute an Applescript which opens an application.* PHP is running under the _www user. And while it can execute Applescripts with the osascript command, it can't ...