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

0
votes
0answers
5 views

CentOs 7 Python Issue “-bash: python: command not found”

I asked this at stackoverflow, but just realized it might be best here. If I need to delete it over there or should not have posted here, please let me know. I am still new to this site. Thanks in ...
-2
votes
0answers
28 views

Detecting the newest file in a directory

I need a Unix script to do the following (in bash) : Accept 1 parameter; (the parameter can only be bo or bot.) Change directory (at this time, this can be determined yourself for now); Detect the ...
1
vote
1answer
32 views

How to get last N commands from history?

I want to see what are the last N commands in my history. I thought history | tail -n 5 would make it, but I noticed that a multiline command counts for as many lines as it has. $ echo "hello how are ...
1
vote
2answers
45 views

How do I get the output of a program already running?

I have a python program that outputs to stdout and a log file. However, the person I am making this for wants to know if I can set it up so that he can see the output of the file, while it is ...
0
votes
3answers
41 views

Bash: increment a variable in a while loop?

Bash newbie here! I have a bash script that for each file in a set, greps each line in the file for a string. Then it splits the line on commas, converts the 7th element to a float, and increments a ...
0
votes
0answers
18 views

Why is Debian's PS1 variable different from the other distros? [duplicate]

I've noticed that Debian's PS1 variable is a little different. For example: root@debian:~# echo $PS1 ${debian_chroot:+($debian_chroot)}\u@\h:\w\$ What is this part: ...
1
vote
1answer
58 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
38 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
29 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
42 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 ...
9
votes
1answer
66 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
15 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
22 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
45 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
25 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
82 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
40 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
71 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
51 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
62 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 ...
2
votes
1answer
59 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
33 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
468 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
33 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
63 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
53 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
31 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
16 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
189 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
93 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
30 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 ...
0
votes
0answers
32 views

How to get the placeholder's value which is stored in a different file (same directory) [closed]

With the conditions: I cannot use any XML parser tool as I don't have permission , read only My xmllint version does not support xpath, and I cannot update it , read only I dont have xmlstarlet and ...
0
votes
2answers
67 views

PATH variable is not working [on hold]

I'm trying to set up PATH like this: export AMBERHOME=/home/pablo/amber14 PATH=$AMBERHOME/bin:$PATH PATH=$PATH:/home/pablo/tinker/bin However the PATH variable seems not to work properly. I dont ...
4
votes
2answers
40 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.
0
votes
0answers
25 views

creating a scatter plot

write function file (1. argument) creates (scatter plot) for n. column (x-axis, 2. argument of the script) and m. column (y-axis, 3. argument of the script), e.g. function= myfun sourcefile 1 3, for ...
1
vote
1answer
24 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
48 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
11 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
158 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
37 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
183 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
47 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 ...
-3
votes
0answers
27 views

Add '/' at the end of line without directing to a file in unix / shell scripting [closed]

Is it possible to add '/' at the end of a line having the pattern SUCCESS? Without directing the output to text file. E.g. When I execute the script the output may have "SUCCESS" pattern. If then I ...
0
votes
0answers
20 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
27 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
90 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
119 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
26 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 ...