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

learn more… | top users | synonyms

0
votes
0answers
6 views

shell script over SSH ends unexpectedly after running 'ant build'

I wrote a shell script that runs on remote host to build source code with 'ant build' command, and then distribute the built binary to other servers. However, right after Ant build is over ...
1
vote
2answers
31 views

In bash, how I define a “command scope” variable?

I'm reading this book on the bash architecture and one of the bash maintainers says: There are different variable scopes for shell function calls and temporary scopes for variables set by ...
2
votes
3answers
49 views

Why is this sudo command try to run in /root?

I try to run a sudo command via SSH like this: ssh domain.com sudo -u user bash -c "cd /home/user/ && ls" (which is obiously just an example). I get back: /home/user/: line 0: cd: /root: ...
2
votes
2answers
5k views

How to ssh with username AND password linux automatically from bash

Im trying to ssh with the Username AND password provided. Restrictions: 1. I DO NOT want to have to set up a public key for each of the servers I am trying to ssh into. 2. I DO NOT want to/have ...
0
votes
1answer
21 views

Alias to connect to AWS instance via SSH not working

I made an alias to make it easier to connect to my AWS EC2 instance. Although there is an error. Here is the code in ~/.bash_profile: alias aws_connect=‘ssh -i /path/to/keyfile.pem ...
1
vote
1answer
144 views

Delete specific line from hosts

I want to delete specific line from hosts file in my home dir: ~$ echo "193.10.1.1 localhost" >> hosts ~$ echo "127.0.0.1 localhost" >> hosts ~$ cat hosts 193.10.1.1 localhost 127.0.0.1 ...
0
votes
1answer
12 views

Open gnome terminals programmatically with a script that requires a doublequote

I am trying to use a wrapper.sh script spawn separate terminals for a script that takes params in doublequotes, like so: #!/bin/bash gnome-terminal -e "./script.py -d "somevalueforscriptpy" $1" ...
1
vote
4answers
85 views

Avoiding users to corrupt and use a script

Is it possible to deny the right to copy files? I have a script which should be executable by others. They are also allowed to read the file (though it would not be a problem to forbid reading). But ...
0
votes
1answer
18 views

How to collect specific data?

I have a text file like this abcdxxxxx abcdxxxxx 1234567 - abcxxxx from that file I want to separate only the strings with abcd as header part. Help me please. Thank you.
4
votes
1answer
647 views

Can I make a custom “directory alias” like '~' in bash?

In bash I can go to my home directory with cd ~ and actually refer to my home directory with any command with ~. Can I make new, custom "directory aliases" (?) to refer to other directories? ...
0
votes
2answers
24 views

Is there any reason this cronjob would fail in cron, but not on the command line?

I have written a little one liner that will email me when a list of files changes - I used sha512 to generate a list of hashes and then periodically check that those hashes still match. */5 * * ...
0
votes
1answer
17 views

Weird output in my mac iTerm bash shell. How do I make it clean?

Setting up my bash and made some mistake. Here is my bash shell: android-c26f663baae722eb:~ okyretina$ I have used a clean .bash_profile and sourced it and the shell still have that weird ...
1
vote
0answers
20 views

How to give each virtual terminal in GNU Screen it's own background color?

I have a dream: I want each virtual terminal within GNU Screen to have it's own unique background color. I think I can fake it in an .bashrc script that emits xterm control codes to set background ...
13
votes
8answers
1k views

Bash Script to repeat every word in a line?

I have a string like: dog cat bird whale And I want to get dog dog cat cat bird bird whale whale All the words are in the same line. Any idea?
20
votes
2answers
12k views

Measure script execution time

In bash shell, is there a simple way for me to monitor the time taken to run a script and output the time taken?
0
votes
0answers
15 views

Raspberry in kiosk mode - How to secure bash or change matchbox for switching tty

I want change my raspberry to a kiosk pc. It works well and is complete, but with some mechanics I've some trouble. The actual problem is, that the autologin mechanism is defeating the purpose of ...
0
votes
0answers
14 views

Automaticly run xinit from rc.local as different user

I'm working on some tuning of my raspberry pi b+. So I decided that midori should start automaticly after autologin. With startx it works without problems, but X is still to ressource hungry. So I'll ...
39
votes
2answers
6k views

Case insensitive tab completion in Bash

Is there any way to make Bash tab complete case insensitively? $ bash --version GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0) Copyright (C) 2007 Free Software Foundation, Inc. I am ...
1
vote
1answer
56 views

How to parse pipe with multiple commands independently?

How can I parse output of a single command by multiple commands without truncating at each step? For example ls -al|grep -i something will pass every line that has "something" in it to the next ...
0
votes
1answer
22 views

How to print index in a 'for-loop' being executed in remote host through SSH?

I want to ssh into a remote host, and then execute a for loop that goes through sequence of numbers to control number of different nodes. ssh user@host /bin/bash << EOF for i in {1..10} do echo ...
2
votes
2answers
47 views

How do I delete all lines but the last one using unix ed editor from a bash script

I have the following bash file called "file" (the real one does something useful): ed db/seeds.rb <<EOF 1,$-1d a 123 456 . w q EOF When I run "bash file" it doesn't delete any lines. If I use ...
0
votes
1answer
30 views

Find a directory only contained within a certain folder

I have a directory structure like: foo |__bar |__bin | |__tmp | |__bez |__tmp I need to find the tmp directory in bin/tmp, but not the one in bez/tmp. It seems to me ...
23
votes
10answers
16k views

Bash: Reset and Clear Commands

I have been using the command: reset to clear my terminal. Although I am pretty sure this is not what I should be doing. Reset, as the name suggests resets your entire terminal (changes lots of ...
3
votes
3answers
10k views

Ubuntu/ Gnome : Open an application in a specific workspace

How do tell an application to open in a specific workspace? More info: I like to have my C++ IDE in workspace 2, my Java IDE in workspace 3, and my email, browser and miscellaneous in workspace ...
83
votes
7answers
69k views

What does 'source' do?

$ whatis source source: nothing appropriate. $ man source No manual entry for source $ source bash: source: filename argument required source: usage: source filename [arguments] It exists, and it is ...
-1
votes
1answer
41 views

How to use HTML markup tags inside Bash script

I have crontab and a simple bash script that sends me emails every often containing PHP, NGINX, MYSQL errors from their log files. This is a simplified example. #/home/user/status.sh ...
0
votes
1answer
24 views

Is \d equal to [0-9] in sed?

7 00:00:30,008 --> 00:00:30,066 by line 8 00:00:31,038 --> 00:00:34,050 or later in the nineteen seventies it was usually a 9 00:00:34,005 --> 00:00:38,634^M video consul but the council was ...
0
votes
4answers
4k views

Why doesn't my symbolic link work?

I'm trying to better understand symbolic links... and not having very much luck. This is my actual shell output with username/host changed: username@host:~$ mkdir actual username@host:~$ mkdir proper ...
1
vote
4answers
30 views

How do I test whether a variable has multiple non-blank lines in bash?

Say I have two variables in bash: MULTILINE="I have more than one line" SINGLE_LINE="I only have one line " I want to detect when a variable actually contains more than one line of text, ...
0
votes
1answer
42 views

Enter response once prompt returns?

It's neither a secure idea nor one I'd recommend elsewhere, but I have a situation when occasionally it takes a while for my Ansible ad-hoc command to respond. I'd love to pipe or args or whatever is ...
0
votes
1answer
31 views

bash doesn't show current working directory on screen

When using iTerm2 on my OS X, the bash prompt shows my current working directory normally: mbp:tp0 renato$ But when I use screen, the bash prompt changes to: bash-3.2$ How I make the bash prompt ...
8
votes
7answers
4k views

Replace Symbolic Links with Files

Is there an easy way to replace all symbolic links with the file they link to?
0
votes
1answer
13 views

Why doesn't the binary package get reinstalled by apt-get or building from source?

I'm trying to install Asterisk on my Debian wheezy server. For this I first did the simple sudo apt-get install asterisk This worked flawlessly. Afterwards asterisk was running and I could enter ...
2
votes
2answers
21 views

How to check if a directory is under svn version control?

From a linux bash script, how can I verify if some directory is under svn version control? I am using svn version 1.7.9. When I try the following pushd ${WD}; svn info; popd and check the error ...
0
votes
1answer
13 views

ssh to production to www-data user

I build an automation for deploys, that we connect to our productions servers and then perform a git pull in the project. The project is owned by "www-data" so I need to to --> ssh ...
0
votes
2answers
34 views

Files listed by bash but unaccessible

What would cause the following behavior on an Ubuntu 12.04 system? I've SSHed into a machine as the "ubuntu" user. Running ls -lah /data/* shows dozens of non-empty files (e.g. file1.txt, file2.txt, ...
0
votes
1answer
19 views

How to get when run `top` command ports listed?

How to get when run top command ports listed ? I get info about process but I need port to see ( process dies very quickly , 0 seconds, and I cannot grep after ps aux ). Is possible to top command ...
0
votes
3answers
2k views

Loop through a directory unix shell programming

Use a for loop to go through the filenames in the directory. In this version, only loop through the filenames that do not have a ".old" extension Inside the loop, rename the file to the new name.
2
votes
3answers
75 views

What is the differences of these concepts(Shell, Terminal, Console and Command-line) in Linux?

As a rookie, these three concepts: Shell, Terminal, Console and Command-line have been puzzling me a lot recently. Especially Console and Terminal?
0
votes
1answer
14 views

How to clean up output from `watch git gc`?

git gc updates the output as it runs, perhaps using backspaces, control characters, and/or curses. (I'm not an expert on this.) How can I modify my watch -n 60 git gc bash command so that the output ...
1
vote
2answers
22 views

two processes are listed for one shellscript?

I have a shell script which does somewhat simple. #!/bin/sh do something boring... When I execute the shell script like this, $ nohup sh mysh.sh > /null/dev/ 2>&1 & I see there are ...
0
votes
1answer
28 views

How to pass output of command to sed

My sed command in #Update key in config file. does not get the contents of the variable $GETKEY Someone help me? # Get key from output of the website. GETKEY=`wget https://www.badips.com/get/key ...
-2
votes
0answers
23 views

What kinds of connection between Enter key on the keyboard and Line Feed or Carriage Return in Linux shell like Bash?

What kinds of connection between Enter key on the keyboard and Line Feed or Carriage Return in Linux shell like Bash? When the Enter key was hit, what does shell receive? Line Feed, Carriage Return or ...
0
votes
0answers
8 views

busybox cp 'are the same file' when copying directories

I'm porting a bash script that worked on OS X to Windows+BusyBox. The first command is to create a new directory mkdir ../new_directory Then to copy all files from the current directory to a new ...
0
votes
0answers
21 views

Check for available command

When I execute the bash script with root user I receive the output it say iptables not exist. Why this happens only with root? for CMDAPP in "hash" "curl" "iptables" do if ! hash "$CMDAPP" ...
9
votes
2answers
3k views

Is there a binary-safe “triple less than” <<< operator in bash?

This is a rather hypothetical question, so please don't ask me why I'd want to do this. Assuming that I have a variable GIF that contains binary data, and assuming that I cannot use the pipe | ...
12
votes
2answers
1k views

Tmux current pane border not obvious

I'm struggling to tell which pane is the current one in tmux if there are only two. The border only seems to highlight the adjoining edge which makes it impossible to tell. Here's a Gif to highlight ...
2
votes
3answers
1k views

What's a reliable technique for killing background processes on script termination?

I use shell scripts to react to system events and update status displays in my window manager. For example, one script determines the current wifi status by listenining to multiple sources: ...
20
votes
3answers
9k views

How to: Unlimited Bash/shell history?

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

How do I chain commands on the console?

In bash, I sometimes want to run several commands in serial and don't want to wait for them to finish before I type the new ones. So I do something like this: cmd1; cmd2; cmd3 Unfortunately, one of ...