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

learn more… | top users | synonyms

0
votes
1answer
75 views

Use date to update date

I am trying to follow along to the exercises in Beginning the Linux Command Line. One of the exercises asks to set the current time to 1 minute ago. While I can get the time one minute ahead: echo ...
1
vote
2answers
21 views

Should I ignore .bash_rc, .bash_profile etc if I'm using Zsh?

Zsh configs go into the ~/.zshrc file. That’s where I’ve been putting my aliases, etc… But I want to know if I should be ignoring .bash_profile and those other files, and putting everything into the ...
1
vote
2answers
33 views

What is the difference between the processes listed by `ps` and `ps -A`?

What is the difference between the processes listed by ps and ps -A ?
0
votes
0answers
16 views

LXC: Automating running an application inside a container

I'm working on a project that automatically compiles, executes and tests the output of submitted programs in C, C++, Java and Python. Obviously this needs to happen inside some sort of secured ...
0
votes
1answer
11 views

Website updating from git (over ssh)

I have a script that I run over SSH, which updates my website from a Git repo. cd website-git git checkout master git pull # Update protected directory rsync -v -a --delete --exclude=db ...
0
votes
2answers
40 views

How to echo string of another string shell variable

We would like to echo the value of a shell variable which has another variable string in its variable name. eg: we want the following output var1=1 var2=2 We tried several various forms similar to ...
26
votes
1answer
14k views

Bash completion for commands in Mac OS X

How do I get fink and macports to autocomplete program names when typing commands, as in Ubuntu's apt-get? For example when I type sudo port install ca and press tab, I want the terminal to ...
28
votes
4answers
13k views

How to: Unlimited Bash/shell history?

Is there a way to define an unlimited history in Bash ?
4
votes
3answers
205 views

How to redirect output of a command to a file when the command will prompt user inputs?

I have a command which will prompt user for some inputs and then output the result to the terminal. I typed the command like below to redirect the output to a file: $the_command > abc.txt But it ...
0
votes
0answers
21 views

Why does sudo -n on Mac OS X always return 0?

It looks like sudo -n on Mac OS X (10.10.3) always returns 0 as a return code. So something like this will always show 0, regardless of whether the user has authenticated with his password first: ...
1
vote
3answers
3k views

Change terminal to open on Bash, not Login

Please help, absolute Mac newb! When i open terminal it comes up with 'Terminal-Login-80x24' at the top and it is requesting a login from me- no idea what this login should be? This is new though, ...
31
votes
3answers
2k views

Have a file named ~ (tilde) in my home-directory

I just noticed that I have a file called ~ in my ~-directory. $ ls -la ~ ... -rw-r----- 1 x1 x1 733962240 Mar 1 17:55 ~ ... Any idea how I can mv or rm it?
4
votes
6answers
5k views

grep count multiple occurrences

Is it possible to do a grep count of multiple occurrences in a file in one single command? For example: $ cat > file blah alfa beta blah blah blahgamma gamma I can do: grep -c 'alfa' file 1 ...
1
vote
1answer
19 views

Run a function from bashrc, but modify exported variable

I am trying to run a function from my bashrc that refreshes every minute and externalizes a variable. It looks like this: export CFN = '' _some_fn { export CFN = 'test' sleep 60 _some_fn ...
23
votes
5answers
11k views

How do I configure ConEmu to run Cygwin Bash?

I created a new task {Bash} passed my home directory /dir "C:\Users\TMB\" and added bash as an application C:\cygwin\bin\bash.exe When I open Bash, it is unable to use the basic ...
2
votes
1answer
132 views

How to make a bash script that names files with today's date

I'm trying to make a script to back up my we servers, but I have very limited knowledge with bash scripting. I want the script to name the backup file ht-"today's date". How would I go about doing ...
2
votes
2answers
59 views

How to recursivly delete all JPG files, but keep the ones containing “sample”

How can I find and delete all the .jpg files in a directory tree with the exception of the ones containing "sample" in their filename? For example : a.zip -> keep it b.jpg ...
1
vote
1answer
21 views

Can't find the good Cygwin shell executable

I am working on Windows 7 and I need Cygwin for my project. I am trying to launch the Cygwin terminal from a Java programm and then write command lines but my problem is that I can't find the right ...
0
votes
2answers
2k views

Bash: exact match of a string with regex

I have to do an exact match on a string with a regex. i have to realize this pattern: toCheck must start with 2 occurrence of $str1, with max 1 occurrence of $str2. If toCheck match the pattern, i ...
6
votes
3answers
537 views

Unable to launch application in tmux

I get this error when I try to launch Sublime Text or SourceTree from tmux: $ subl Unable to launch Sublime Text 2 $ stree Unable to open SourceTree It seems that I can't open os x apps either: $ ...
1
vote
3answers
2k views

How to define alias for command which will be available in shell script?

Here is a part of my .bashrc alias my_command="my_command -1 -2 -3" and its my shell script #!/bin/sh my_command blah blah blah It occurs into error ./aa: line 2: my_command: command not found ...
0
votes
0answers
16 views

Why the process of sleep command is always in sleep status?

Why the process of sleep command is always in sleep status ? Sleep status means waiting for I/O right ?
7
votes
3answers
5k views

Lightning bolt for prompt (PS1)

I've seen on a few screencasts a while back where someone had a lightning bolt instead of $ on the bash prompt. Does anyone know how to do this?
1
vote
2answers
34 views

SSH-AGENT could not open connection

I try to link my SSH key with SSH Agent. I'm on Windows 7 Pro, and I'm using Git Bash console. I've this folder structure: C:\Users\MyName.ssh\id_rsa Where I've put my SSH key files as follow: ...
11
votes
4answers
1k views

Who deals with the star * in echo *

Who deals (interprets) the * in echo * Does the echo see the star or the shell take care about it and return a list of filename .. What about cp temp temp*
1
vote
1answer
25 views

How to serach for a line which contains specific string in Bash?

I've got a file which contains some amount of lines, I want to look for a specific string, and if the file contains it, then I want to print a different line from the same file. for example, let's ...
1
vote
5answers
2k views

Bash/csh: test for end of file (EOF) of stdin

I would like to do: if not eof(stdin): pass stdin to program else: do nothing I have a feeling that it can be written fairly close to: if test ! --is-eof - ; then exec program The ...
0
votes
0answers
10 views

Creating a Package installer that will run an already made package installer

I am new to creating package installers. I am looking to create a package installer that First Runs an already created .pkg file (printer Drivers) then runs a post bash script that configures the ...
0
votes
1answer
34 views

Rsync delete only remove older source files

Ok, I could probably spend a lot of time writing a complex set of bash scripts that would accomplish this, but I'm hoping this functionality already exists somewhere. I have a device in my car which ...
11
votes
13answers
18k views

Monitoring a file until a string is found

I am using tail -f to monitor a log file that is being actively written to. When a certain string is written to the log file, I want to quit the monitoring, and continue with the rest of my script. ...
0
votes
0answers
31 views

How to encrypt data in bitbucket without losing git diff tools?

Based on this question:encrypt files before sending them to cloud. considering openssl: For example when using openssl we can write the files fooenc.sh: #!/bin/sh openssl enc -bf -nopad -pass ...
2
votes
1answer
23 views

Bash completion: global expansion by presing tab

In my desktop computer with opensuse 13.1 I can press tab in something like ls *.dat[TAB] and I get the autocompletion or with [TAB TAB] a list of possible matches. However, in my laptop with ...
0
votes
4answers
27 views

What issue exists when multiple lines of 'date' are used in bash?

I'm currently reading through a book on bash programming, Pro Bash Programming. At one chapter (Chapter 4) they ask what problem the following script has. I myself have no clue after reading through. ...
1
vote
2answers
3k views

How to auto commit to my git repository using cron?

I look into a lot of answers about this subject, but something is wrong here, let me explain. I create this script, to make my cron cleaner :) #!/bin/bash cd ...
116
votes
3answers
95k views

Go back to previous directory in shell

Is there a way to go back to previous directory we were in using bash,tcsh without using pushd/popd ? I'd like to type something like "back" and got returned to the previous directory I was in. Edit: ...
1
vote
2answers
17 views

How to add the filepath to a specified line of a file using bash script?

I have the following bash code: echo "Enter an input path" read -e input_path OLDTEXT="\put(0,0){\includegraphics{/" NEWTEXT="\put(0,0){\includegraphics{$input_path/" find . ...
1
vote
1answer
18 views

Bash completion for cd alias

I'm using the following function to list the directory contents after changing the current working directory: function c() { cd $@; ls; } How can i enable bash directory name completion for the ...
-2
votes
3answers
730 views

How to run apache server if it not already running

I wonder if it is possible to check whether or not apache2 is running. If it is not running I want to execute it using shellscript Currently I have added a function which I named run_apache which ...
0
votes
1answer
31 views

How to select files with spaces in their name in a terminal?

When using gnome-terminal which is the default on Linux Mint, I can select files using a double click. For example: user@hostname $> ls 1.file.name 2-file-name 3 file name with spaces This ...
0
votes
1answer
34 views

Older History of commands linux

I want to check history of commands on my linux server that dates 1month and 4 days old, but the history is showing up to 1 month only (I was late checking it earlier). I know the ' History ' command ...
3
votes
2answers
60 views

Parse file from certain line onwards in bash on Linux

I have a CSV file containing the following registers: Name,Phone,Country John,N/A,USA Max,N/A,USA Name,Color,Size John,Blue,M Max,Red,S How can I read only the registers from Name,Color,Size and ...
1
vote
2answers
3k views

Mac Terminal showing bash instead of my username

This makes it hard to know what directory I am in. I installed a version of python for school and now it says -bash-3.2$ instead of MyMacbook: ~$. I'm sure this is really simple, but I know nothing ...
1
vote
1answer
41 views

Is there a way to run a specific script with every “halt” and “reboot” command on Linux?

I need to find a way to somehow intercept the halt and reboot commands and execute different actions via shell script before the actual halt and reboot commands are executed. Is that possible without ...
2
votes
1answer
16 views

How to substitute all occurrences after a certain number with sed in OS X

I am trying to modify a bad .csv file, where the last 'column' is broken into a different number of columns due to extra , characters. I want to use sed to keep the first 4 commas, and replace the ...
0
votes
1answer
26 views

CPU Load + Frequency per core in linux terminal?

I am doing scientific computing and I need to keep an eye on the cpu frequency and load of each core (there are 2 cores, on Ubuntu 14.04 w/ Gnome3). I can see the frequency with this bash script: ...
0
votes
2answers
492 views

Is it possible to run a dialog/whiptail script in one TTY from another?

The origin of this question, for me, is being able to run a whiptail command in a %pre script from a kickstart file when installing a custom distribution based on Centos. However, the behaviour ...
0
votes
2answers
30 views

Thunar custom command: Keep Terminal open

When I make custom commands for Thunar with the xfce4-terminal -x command, sometimes I'd like to see the Terminal output of the command. How can I prevent Terminal from closing after the command is ...
3
votes
1answer
180 views

one sudo for multiple terminals

Sudo root permissions are given for specific time, but only for one terminal. If I want to use sudo in another terminal in that time period, I have to type password again. How to force sudo to works ...
0
votes
4answers
60 views

While loop Bash script that outputs how many users use a certain shell

So I am stuck on trying to create a bash script while loop function that takes the input from /etc/passwd and outputs how many of users use bash, nolongin, csh, and ksh. I believe I am supposed to ...
0
votes
1answer
26 views

Cronjob: Iterate through files

I want to iterate through a list of bash scripts with a cron-job. I.e. every two hours I want to start another bash script. My idea was to set a new environment variable, each time the cronjob script ...