Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [bash]

Bash (Bourne-Again SHell), is the shell used in Ubuntu's command-line interface by default.

0
votes
1answer
17 views

How to open several Terminal Tabs and open files in Vim and change directory?

I'm asking this question because I tried a lot of solutions I found and they all didn't work: gnome-terminal --save-config=... results in an error that this option is no more possible gnome-terminal -...
1
vote
0answers
13 views

18.04: Bracket match not found in .bashrc with Gedit or Mousepad?

OS: Ubuntu 18.04 or Kubuntu 18.04. I have Gedit 3.28.1 on both systems. While looking at .bashrc or /etc/skel/.bashrc, I found an instance of "bracket match not found" as shown in the image below in ...
1
vote
0answers
32 views

bash script started through cron (root) not ending as expected

I have a script as follows, and I am trying to run it as a root cron job. The script starts mycommand, which in turn starts another process. When a condition is met, I would like the script to kill ...
0
votes
0answers
17 views

How to copy with scp many files but ask passphrase only once? [duplicate]

I need to write bash script with many copying files to remote server and in back direction. I am using ssh keys, stored locally in .shh and allowed on server. I try this scp user@ip:/site/{conf1,...
0
votes
0answers
17 views

how to make a bunch of command to automatically run as root on wakeup from suspend?

I have seen lot of answers on this nothing seemed to work on my system (probably I did mistake) I have dkms module of wifi installed which does not reload itself when I resume from suspend. So i need ...
0
votes
0answers
37 views

How to execute script on my Ubuntu via PHP from site

How can I use PHP to execute a script on my Ubuntu server? The site is hosted on the same machine obviously. I read about exec_shell() and tried this <?php $output = shell_exec("ls /var/www");...
3
votes
2answers
72 views

conditional find output missing

Im trying to build a conditional statement to search for files of a certain size (in this case 1Gb. if [ "find /location/sub/int/ -size +1G" ] then > /location/sub/int/large_file_audit.txt fi ...
1
vote
1answer
50 views

How to replace consecutive characters from directory names, recursively

What is the best way to replace all consecutive characters such as _+-."'? from a directory and all sub directory's names using GNU bash, version 4.3, using tools awk, sed, Perl rename or find? The ...
5
votes
2answers
262 views

Bash script to verify if a process is running is not working

I have a simple script as below which checks if fail2ban service is running or not on Ubuntu 18.04: #!/bin/bash # Script to check if fail2ban service is running if pgrep -x "fail2ban" > /dev/...
0
votes
1answer
22 views

Cut the second field delimited by spaces

I want to retrieve the second column from ps result: test@pc:~$ ps -e | head -5 | cut -d '' -f1 PID TTY TIME CMD 1 ? 00:00:03 systemd 2 ? 00:00:00 kthreadd 3 ? ...
0
votes
0answers
23 views

VIDEOIO ERROR:V4L: Can't open camera by index 0

On a Intel NUC, I have loaded Ubuntu 16.04. I have disabled the desktop module by making changes to /etc/default/grub. The machine boots in text mode. I have a python program that uses Opencv (...
1
vote
1answer
37 views

How to escape a single quote inside a double quote string in bash script?

I am trying to run the follow bash code: #!/bin/bash export DEBIAN_FRONTEND=noninteractive DB_USER='abc' DB_USER_PASSWORD='123' DB_MAGENTO='db_magento' sudo apt-get update echo debconf mysql-...
0
votes
1answer
15 views

Git completion fails after updating to Ubuntu 18.10 Cosmic Cuttlefish

I recently updated to Ubuntu 18.10 and after that my git completion has been failing. Bash is able to complete the first command successfully, for example (I'll use ↬ to indicate TAB was used) $ ala↬...
0
votes
1answer
32 views

Ubuntu changing background color in text mode boot

I have changed the setting in my ubuntu desktop 16.04 to boot only on command line mode. Upon reboot, the interface that opened had black background, text in white, directories in blue and so on and ...
1
vote
3answers
81 views

Move files from subfolders

I've been beating my head against this for a while, but I'm really not a good script writer. Apologies... I'm running Ubuntu/gnome 18.10, and have a large set of pictures exported from my wifey's ...
0
votes
0answers
21 views

Create plugin/node for trimmomatic using GKN

I want to create a plugin/node using GenericKnimeNodes for trimmomatic.Trimmomatic is a java based tool. Please, can you give me an example or tips how is shell script to write in order to make jar ...
2
votes
1answer
26 views

Collecting the origin directory of a Bash script from itself [duplicate]

Is there a way that a bash script detects the path directory in which it's running? It is like if the script is aware of where is it. In order to use files that are in the same location as the script....
0
votes
1answer
20 views

Move files into specifics folders with almost same patterns

I have actually a directory where I have different file such as : So let say in the directory : /path1/ncbi_genomes Sp_1.fna Sp_2.fna Sp_3.fna Sp_4.fna Sp_5.fna and another directory with folders ...
0
votes
0answers
17 views

What does search bar invoke when to open a software

I installed a GUI dictionary - goldendict. It could be opened from terminal me@me~$ goldendict QFileSystemWatcher::removePaths: list is empty QFileSystemWatcher::removePaths: list is empty or ...
0
votes
1answer
16 views

How to check my quota from terminal using LDAP

We are using a (synology) fileserver in combination with LDAP to host all the home directories for our users. Every user gets assigned a certain quota of how many GB he is allowed to use in his home ...
0
votes
1answer
34 views
+50

Move specific column from csv file in front (select column by name)

Consider this data: #!/usr/bin/env bash cat > example_file.txt <<EOL group, value, price 1, 3.21, 3.21 1, 3.42, 4.11 1, 3.5, 1.22 2, 4.1, 9.2 2, 4.2, 2.11 EOL I want to move the 'value' ...
2
votes
2answers
56 views
+50

System wide variables for both init scripts and system?

I created my own init scripts that use variables: #! /bin/sh case "$1" in start) echo "Starting Public API" sudo -u techops sh ${JBOSS_HOME_PUBLIC_API}/bin/standalone.sh > ${...
-1
votes
1answer
43 views

bash split file chunks to array

I have the command to split the file in to chunks of 2 lines split -l 2 urls.txt It creates some random files. I have a scenario when I want to split the urls.txt into 2 lines chunks much like php ...
1
vote
1answer
83 views

bash function implement python command

I have this python -c "import sys, urllib as ul; \ print ul.quote('sample hihi ')" How can I wrap it into a bash function, so I can call it like a function like so: urlencode('sample hihi ') ...
0
votes
2answers
46 views

alias not working inside bash shell script

When I search for .bashrc files in my system I get: /etc/bash.bashrc /etc/skel/.bashrc /root/.bashrc /usr/share/base-files/dot.bashrc I changed: /etc/bash.bashrc /root/.bashrc I added the alias....
0
votes
1answer
61 views

How to delete a line from a file containing sh extension?

I'm using Ubuntu. I have an fileName.sh file containing 1000 lines and I have to delete the 399 number line is this command is sufficient for the deleting the line. Command:- sed -i '399d' test.sh ...
1
vote
1answer
21 views

When I use variables that are defined in a code that will be pasted in another file it shall not be printed in the file. Why?

echo "x=0 while true; do ((i++)) cp file1 file1$x done " >> file1 ` When I use variables that are defined in a code that will be pasted in another file it shall not be printed in the file. Why? ...
0
votes
2answers
47 views

Apt-get install -y [duplicate]

When you run the commandsudo apt-get install -y Vivaldi Vivaldi being an example, but what does the `-y` Argument achieve?
3
votes
3answers
452 views

shell script to remove files didn't work

I want to delete multiple images having resolution less then 228x228. For that, I wrote this shell script: #!/bin/bash for i in $( ls ); do if [$(identify -format "%w" $i) < 228] && ...
1
vote
2answers
64 views

Enable automatic updates from command line

I'm creating a BASH script that will, among other things, enable automatic updates, important security updates, and the "Check daily" option in the software updates menu. But no matter where i search, ...
0
votes
0answers
40 views

problem to run script.sh in crontab [duplicate]

I would like to run a script with crontab -e. I'm running ubuntu 18.10. In terminal it works. #!/bin/bash #themes day=Yaru night=Yaru-dark #time time_start=7 time_end=20 currenttime=$(date +%H) if ...
0
votes
1answer
72 views

what is wrong with my guessing game [closed]

#!/bin/bash # this programe random numbers between 1 and 100. clear echo "Hello, "${USER} date; n1=$[($RANDOM % 100) +1] guess=1 echo -n "I'm think of a number between 1 and 100. guess:" while read ...
0
votes
0answers
52 views

add-apt-repository command not working [duplicate]

I'm new to Ubuntu and I tried to install something and the guide I was reading says to run a command that starts with sudo add-apt-repository but whenever I try to use the command then it says bash:...
1
vote
2answers
93 views

Automate the mysql secure installation using shell script

I am trying to automate mysql secure installation using linux shell scriping. I have below code got from https://gist.github.com/Mins/4602864. #!/bin/bash MYSQL=$(grep 'temporary password' /var/...
0
votes
1answer
30 views

My bash arithmetic always evaluates to 0, no matter what

I type in the script: result=$(( ($1-32)*(5/9) )) echo $result and the result variable always evaluates to zero, no matter what value $1 is. How do I solve this problem?
0
votes
1answer
32 views

gnome : where does my keyboard input go?

I run Ubuntu 16.04, terminals using gnome-terminal, and bash as shell. Sometimes, one of my terminal becomes unresponsive : when I press keys on my keyboard while the terminal is focused, nothing ...
1
vote
1answer
85 views

How to solve this error `sudo: /usr/local/bin/sudo must be owned by uid 0 and have the setuid bit set` without reinstalling ubuntu?

TLDR: I am running Ubuntu 18.04 with i3 and I messed up my permissions. Whenever I run a command with sudo, I get this error message, sudo: /usr/local/bin/sudo must be owned by uid 0 and have the ...
1
vote
1answer
38 views

Change global environment variable using a script that is started using xbindkeys?

TLDR: I have a simple shell script that flips an environment variable from value foo to bar, or the other way round, depending on its current value. I use F12 to trigger this script, and I know that ...
0
votes
1answer
45 views

Use find to find a directory and move it to a different path

I have hundreds of thousands of files in hundreds of directories. An example directory structure is ./main/foo1/bar/* ./main/foo2/bar/* ./main/foo3/bar/* ./main/foo1/ran/* ./main/foo2/ran/* For ...
22
votes
3answers
2k views

Terminal shows > after entering \

When I press backslash \, I’m given a > (greater than) symbol. What does this mean?
3
votes
1answer
57 views

How to suspend/resume cronjob if one is already running?

I've tried this solution to prevent duplicate cronjob from running. 30,31 12 * * * /usr/bin/flock -n /tmp/my.lockfile ~/Desktop/test.sh >> ~/Desktop/test.log 2>&1 and script test.sh has ...
1
vote
2answers
58 views

How does Command substitution, dig and +short work within this script?

Could someone please explain how dig and +short work within this script and why they are used? Also could someone explain how the command substitution works within the code as I am struggling to ...
1
vote
1answer
40 views

How would I ping IP address produced from script?

Scripting novice here. I have created a script which can show you the ip address of the website which has been entered. My script: ! /bin/bash echo "Enter web address : " read address echo "...
3
votes
1answer
201 views

Duplicate rows in text file

I need to duplicate rows in text file with a specific number of times. For example my data file is: jplg3350.18i jplg3360.18i jplg3370.18i I need to duplicate the lines three times as follows; ...
2
votes
0answers
32 views

Opening applications with random theme

I'm using Canvas GTK theme and have all colors of that theme on my system. I want to use one of those Canvas themes randomly each time I open an application. I know I can use env GTK_THEME to open ...
1
vote
2answers
21 views

unexpected EOF and syntax error: [closed]

I can run below codes line by line using terminal without problem but when I run the script file I got line 14: unexpected EOF while looking for matching `"' line 30: syntax error: unexpected end of ...
3
votes
2answers
231 views

How do I use command-line arguments to `sh` in the `-c` command string?

I know that sh -c 'echo $1' sh 4 will output 4. and sh -c 'echo $2' sh 4 5 will output 5. But I cannot understand how the parameters after the second sh were passed to the command next to sh -c. ...
1
vote
1answer
33 views

How to list and remove files only if multiple conditions are met

This is on ubuntu 18.04. I have access to bash, pip3, and ruby gems on this machine. Trying to work with multiple mp4 files that were sent to us by VHS converter company. Each file has at least a ...
0
votes
1answer
107 views

bash: build/envsetup.sh: line 1: syntax error near unexpected token `$'{\r'' [duplicate]

I have my server running Ubuntu 18.04 LTS, I used it to host my personal stuff, stream media, bots and doing android builds. A month ago I saw some errors while executing the envsetup.sh script that ...
1
vote
1answer
34 views

How would I export information produced from script onto a text file [duplicate]

Scripting novice here. I have created a script which can show you the ip address of the website which has been entered. My script: #! /bin/bash echo "Enter web address : " read address echo "...