Questions about bash only, as opposed to other Bourne/POSIX shells. For all Bourne/POSIX-style shells, use the /shell tag instead.

learn more… | top users | synonyms

1
vote
1answer
62 views

Ctrl-Y, emacs styled yank text is not working when user is switched

I cut the bash command line text using Ctrl-K. The line got cut. Now, I ran sudo su to become the root user. I tried to paste the command that i cut as non-sudo user using Ctrl-Y. It is no longer ...
4
votes
0answers
47 views

How can I make tmux tell bash to display the *logical* version of the current directory in newly opened windows?

Background I'm using tmux 2.0, Ubuntu 14.04.2 LTS in VirtualBox. In my ~/.tmux.conf file I have the line: bind c new-window -c "#{pane_current_path}" to make tmux open new windows with the same ...
0
votes
1answer
31 views

Linux: Test if in maintenance mode?

I want to run some things differently if I have booted into single-user/maintenance mode. I want to know how I can test in my .bashrc, in particular I would like to start tmux only in that mode, to ...
0
votes
2answers
47 views

How do I create a user bin directory in gentoo

I would like gentoo to allow users to have a bin directory which is added to the PATH variable for that user. The directory would be located at /home/user/bin. Where is the best place to set the PATH ...
13
votes
1answer
177 views

Update bash history on others terminals on exit of one

I know this question has a similar interpretation, as its asked here keep updating (and duplicated here). But what I'm trying to achieve is a bit different. I don't like the idea of my prompt ...
0
votes
1answer
18 views

Substituting the value with spaces for a variable in bash script - the correct way

I have a compilation script that can compile the program with and without the debug symbols. I want to ask via bash prompt ( read ) the user to choose whether he wants a debug version or not with ...
0
votes
1answer
29 views

Export mysql to remote server using one SSH session

I've come across a situation where I had to create a utilitary shell script that would be executed in many servers from different regions. The objective is to dump the local mysql database, copy it to ...
0
votes
1answer
46 views

Issue a command in each directory

I have 3 directories: dir1 contains two subdirs. In every subdir there is a slackbuild. I want to build all slackbuilds, staying in the parent directory. I have tried (cd *;sh *ld) But it only ...
1
vote
1answer
29 views

bash: Passing several space containing filenames

In a bash script I am rasterizing a PDF page by page into single files, in the end the single resulting PNGs are merged again into a PDF like this: convert -monitor /path/to/1.png /path/to/2.png ...
4
votes
3answers
98 views

-bash: unalias: ls: not found

I am trying to install tomcat 8 on centos 7. I am using the terminal as root. When I type in source ~/.bashrc, the terminal gives back the following error: -bash: unalias: ls: not found. How can ...
1
vote
1answer
46 views

Syntax error at a semicolon in a shell script

The one liner command will be longer but this is the part that is throwing the error. for user in natural1 ; do cat <<EOT >> /home/$user/public_html/.htaccess <FilesMatch ...
0
votes
2answers
76 views

Special meaning of '{}' ';' with find

User-define action is a feature of Bash in linux. In Linux terminal if I write root@localhost: find ~ -type f -name 'foo*' -ok ls -l '{}' ';' then it checks if there is any filename starting with ...
-3
votes
0answers
55 views

Bash Shell - Grep a line from a file - append from an entered variable and query that line?

I would like to grep a line from a txt file use that line and append the variable used "entered from the user. Get the output of the grep add variable with a space and then query that line. Any ...
2
votes
1answer
66 views

Convert IP Address to Coordinates using database

I have a file which contains IP and I wanted to compare it to Coordinates using a local database (instead of API). I tried following a process and break down to pieces and created scripts referring ...
3
votes
1answer
63 views

How can I run my program without having to type ./?

My teacher wants to be able to compile our programs without having to type ./. For example we would write: g++ some_program.cpp -o some_program some_program He says to type: cp .bash_profile ...
0
votes
1answer
39 views

why are colors mixed up in CentOS 7 terminal?

I have CentOS 7 running as a guest OS inside a VirtualBox host. I opened a terminal to write some commands, but the colors are all messed up as shown in the following print screen: It looks ...
5
votes
6answers
499 views

How do I check if a variable exists in bash?

I need to check a variable's existence in an if statement. Something to the effect of: if [ -v $somevar ] then echo "Variable somevar exists!" else echo "Variable somevar does not exist!" ...
-1
votes
2answers
35 views

Enter a variable into a command in bash

My question should be simple for you guys. I am writing a simple script that runs a command but the file it would need is always different. Is there a way for it to ask: "Where is the file?" And ...
0
votes
2answers
34 views

Replace spaces by underscores in files: Error in my bash script

I don't understand the error in my bash script. #!/bin/bash newFile="" for file in * do newFile={$file/ /_} # so as to replace spaces with underscores mv {$file} {$newFile} done It ...
2
votes
2answers
67 views

Compare 2 Files if it falls between a range of numbers

I have 2 files, File 1: 4 7 2 File 2: 1 5 Alpha 6 10 Bravo 11 15 Charlie 16 21 Delta 22 30 Echo I want to compare every entry in file 1 if it lies between col 1 and col 2 of file 2 (should be ...
0
votes
2answers
58 views

How to execute multiple .command files simultaneously?

I have a folder of .command files (regular task) on Mac OS X , which i would like to execute simultaneously. At the moment, i have been iterating through each file in the directory one by one to ...
0
votes
4answers
32 views

Test if integer series is strictly increasing

I would like to test if a list of integer values (e.g stored in a file, one per line) is strictly increasing, using a bash script. Is there any simple/concise way to achieve that?
1
vote
0answers
20 views

GNOME 3.14+ launch new gnome-terminal and set title

To the disappointment of many, tab/window title can't be set anymore with --title I use bash. I have had a few aliases I have used to connect to remote servers with. alias c:prod='gnome-terminal ...
1
vote
3answers
199 views

Put big data of heterogenous byte offset into arrays by AWK

Assume the data consists of byte offset which is not fixed i.e. the distance of two subsequent file headers varies. The point of this thread is to go through each size of events separately in arrays. ...
4
votes
2answers
99 views

How to search for and replace text between two markers in bash script, with content from another file?

Say I had a block of text in the ~/.bashrc: #~/.bashrc # ...some commands... # aliases alias suicide='sudo rm -rf /' # end aliases # other commands I wish to replace that block of text with some ...
4
votes
1answer
32 views

Aliases fail to persist after sourcing script

Here is my script: echo "Defining aliases" echo $$ echo " s=screen v=vlock -a j=jobs " | sed '/^$/d' | while read alias do echo $$ alias "$alias" alias | wc -l done And here is its output: ...
0
votes
1answer
17 views

Comparing Oracle version in bash script

I'm trying to create a bash script to install an application that requires Oracle 11g client. How can I read in the version info within the bash script? sqlplus when run in Putty spits out the ...
4
votes
2answers
41 views

How can I disable bash traces?

For any command that I execute in the terminal a comment like + command appears. For example for ls it shows + ls --color=auto.
1
vote
1answer
27 views

Magic environment variables in gnome-terminal

I had installed a proxy software (cntlm) on my machine. It sets the environment variable http_proxy to 127.0.0.1:3128. Now I've uninstalled the program using apt-get remove cntlm. However I'm able ...
0
votes
1answer
54 views

Remove the exact same matching lines with sed

I have this bash script: sed -i -r '/deb http\:\/\/httpredir\.debian\.org\/debian jessie main/d' /etc/apt/sources.list sed -i -r '/deb http\:\/\/httpredir\.debian\.org\/debian jessie\-updates main/d' ...
0
votes
1answer
12 views

how to access through the matches in file-name completion?

In case of file-name completion, is there a way to access through the matches that get displayed after a double tab?
2
votes
2answers
164 views

Slash and backslash in sed [duplicate]

I want to use sed to change a slash into a backslash and a slash, i.e. / -> \/. But it does not work. Here a small example: #!/bin/bash TEST=/etc/hallo echo $TEST TEST=$(echo $TEST) echo $TEST ...
1
vote
2answers
40 views

How can I delete <93> <94> symbols in file? It is equivalent “ ”

I copied text from a PDF file in bash - vi and I get lines like this: echo <93>The Hypotenuse is $hypotenuse<94> I tried to change that in vi by: s/<93>/"/g But: E486: ...
4
votes
6answers
199 views

Loop in text files shell script

I have a list of files in one directory and a set of jpegs corresponding to each file in another directory. I need to loop over all files, and for each file name, determine the target directory. For ...
4
votes
2answers
49 views

date processes first parameter incorrectly if it is not 1

I am using date (GNU coreutils) 8.22 and having some trouble to calculate a date after a given one. Say I want to use 1st of February, for example: $ date -d'1 February' Sun Feb 1 00:00:00 CET 2015 ...
0
votes
0answers
21 views

how to hardsubbed avi files with Hnadbrake CLI bash script

is there a way to hardsubbed avi files with Handbrake CLI ? i use this bash script below to convert all avi files in a directory but have no idea how to make hardsubbed video with this bash script. ...
2
votes
2answers
30 views

How to run x instances of a script parallel?

I have script I'd always like to run 'x' instances parallel. The code looks a like that: for A in do for B in do (script1.sh $A $B;script2.sh $A $B) & done #B done #A The scripts ...
0
votes
3answers
103 views

Where is .bashrc file found in Linux?

I am not finding my .bash_login and .bash_profile root@linux:~# locate .bash* /etc/bash.bashrc /etc/skel/.bashrc /etc/skel/.bashrc.original /home/noroot/.bashrc /home/noroot/.bashrc.original ...
2
votes
4answers
120 views

How to see if there are any matching characters in a string?

I'm making a card hand generator, and I want it to note if a specific hand is generated, like a three of a kind or a full house. I was trying to figure out how to do it, and I thought of using grep on ...
0
votes
1answer
28 views

Clear terminal window before tail -f output

I have the following script running every 3 minutes with cron: #!/bin/bash cd ~/Documents/Fetch/ wget remotehost/data.txt --output-document=tmp cp tmp data.txt rm tmp To fetch a self-generated php ...
0
votes
3answers
33 views

Shell pattern matching and arithmetic operators (+ - * / %)

This looks so simple but it isn't: [[ "1234+5678" =~ [0-9]+(\s*(\-|\*)\s*[0-9]+)* ]] && echo $? returns a 0. However, it actually should not do that, as only minus (-) and multiplication (*) ...
-1
votes
1answer
89 views

mv command does not work in shell script [closed]

I want to rename a folder with a bash-script. I don't know why this command is not working in a shell script, but directly in the terminal is working without problems. ...some code... ...
8
votes
9answers
438 views

awk or sed to lowercase/uppercase only one character in string?

Is there a way how to uppercase/lowercase only one character in some string? Input Example: syslog_apr_24_30 syslog_mar_01_17 Desired output: syslog_Apr_24_30 syslog_Mar_01_17 Note please the ...
-4
votes
3answers
34 views

find and replace strings with another string command line

I have a Ad-blocking hosts file with 0.0.0.0 IPs pointing to URLs. How to replace 0.0.0.0 with 127.0.0.1 command line without any visual text editor ? Manually doing this with nano , vi etc. is ...
1
vote
3answers
72 views

How do I get the current line count from xargs?

I want to grab every 5 images in a directory and merge them together into a new file with a unique filename per 5 image group. find *.jpg | xargs -n 5 -i convert {} -append {#}.png This is really ...
0
votes
1answer
13 views

How do I change the keybindings for the dialog command

According to the documentation here: You can override or add to key bindings in dialog by adding to the configuration file. Dialog's bindkey command maps single keys to its internal coding. ...
2
votes
0answers
34 views

How prevent users from running commands via dot slash for a directory?

Does anyone know if it is possible to restrict execution of commands via dot slash notation for a directory? The environment is bash on Linux. For example, I have a directory /usr/local/app/bin. In ...
0
votes
1answer
26 views

Terminal doesn't calls 'then' a syntax error, command not found [closed]

I am a newbie for linux. I have centOS7. I am running a very simple script from BASH. I execute the chmod command and then run the script file from terminal, I get an error saying that if command not ...
0
votes
2answers
62 views

Bash script that detects if a file is the correct size

I'm trying to make this bash script dispatch and email when it detects that a certain type of file (files ending in ".gz"), which was last modified 24 hours ago, is below a certain size in a ...
-1
votes
1answer
44 views

inittab respawn and rc.local

At the moment I have a daemon starting at boot using rc.local by the following line. su -l user -c '/dir/daemon' but I would like to start this process as a service with respawn. I found out that ...