Questions tagged [bash]

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

Filter by
Sorted by
Tagged with
1
vote
1answer
19 views

Problem parsing piped command streams in python, need help

Wanted to convert my bash script to python. The script sensors | grep "Core" Returns a nice output easily parsed, one line for each core of the CPU and if read into an array using IFS=' ' read -r -...
0
votes
1answer
38 views

Linux command for finding unique file contents in many text files

I have a bunch of files displaying error messages, each of which has a traceback. Many of these have the same error message, and I'd like to have a list of all unique error messages in every file. How ...
0
votes
0answers
21 views

Passing in bash arguments from a variable that has quotes

I'm trying to build an Nginx module. The instructions I had found have this configure line: ./configure --add-dynamic-module=my-module-path $(nginx -V) Which runs without error but the module that ...
1
vote
0answers
20 views

invalid desktop file

I have a simple script I want to be able to run from a Desktop on Ubuntu 19.10. I followed these directions and created a .desktop file but I'm getting an error saying it is invalid. Here is the error ...
2
votes
1answer
64 views

Possible to read “lines” from a variable?

I have been reading lines from a file I created and would like to use a variable and avoid writing to storage. Not sure if this can easily be done. The working code starts off as follows sensors | ...
0
votes
1answer
36 views

How do i stop / fix the spam error mkdir failed: File exists [closed]

I'm trying to do a CTF that the Danish government has released in order to recruit new hackers. I don't know much about this but I overcame the first challenge and I hope to learn a lot from this. ...
0
votes
2answers
29 views

Creating several files in different directories

I need to create 1000 input files containing: x=i, i varies from 1 to 1000 y=5 Each file is to be placed in a separate directory. I tried: mkdir inp cd inp max=1000 for ((i=1;i<=max;i++)); do ...
0
votes
1answer
36 views

Ubuntu 18.04.3: Set the environment for bash script that runs through Gnome Startup Application

On Ubuntu 18.04.3 GUI, I am using GNOME Startup Application to start my bashscript because @reboot for cron doesn't work for me (cron - crontab's @reboot only works for root? - Unix & Linux Stack ...
0
votes
0answers
31 views

Exiting shell with new command line

I'm running a third party Java program on a VM instance on Google Compute Engine with Ubuntu 18.04. I have an automated workflow that runs the Java program via SSH and executes my desired function. ...
0
votes
2answers
51 views

How to manipulate specific fields?

I have a csv file. Its line numbers are max 25. Headings are time(UTC)(1st field), latitude(2nd field), longitude(3rd field), depth (4th field), mag(5th field), place (14th field) and so forth ...
1
vote
0answers
38 views

Bash script stops when running chromium

I have a bash script that runs a chromium instance, but the script won't continue executing until I close chromium. Is there any way to run Chromium and continue the script? The same happens when ...
0
votes
0answers
16 views

CUDA Path Not Correctly Configured

I am trying to change my environment path variables so Pytorch can access CUDA. According to nvidia-smi, the driver can support CUDA 10.0. CUDA 10.0 is already installed on the server. I modified my ...
2
votes
1answer
43 views

Extract a specific pdf from a zip file with lots of pdfs

Given: Name and Location of Zip-File. Example: collectionOfPdfFiles2017.zip Zip File is a collection of PDFs without folder structure Name of PDF File in Zip-File. Example: someFileFrom2017.pdf ...
0
votes
1answer
35 views

Moving files to a different folder, ignore the existing files

I want to move all the files from parent folder to child folder... and ignore the existing files in the child folder, i.e. if img1.jpg exists in both parent and child folder, it should not be replaced ...
0
votes
1answer
51 views

How to permanently change a PATH variable in Debian [closed]

I'm trying to change the directory that is accessed when I call blender in my terminal. This is currently where it is: ...$ which blender /usr/bin/blender And I'd like to instead use the version ...
-1
votes
0answers
27 views

Changing shell for root

I've been following this guide to switch my shell to zhs. However when I get to running this: chsh -s /usr/bin/zsh root I get the following error: You may not change the shell for 'root'. Is this ...
5
votes
4answers
584 views

How to replace libapt-private.so.0.0.0 manually on Ubuntu for Windows?

I'm using Ubuntu for Windows, and have been for some time. /etc/debian_version names it as buster/sid. As a result of recent suspected disk corruption, /usr/lib/x86_64-linux-gnu/libapt-private.so.0.0....
0
votes
1answer
35 views

How terminal decides which program to open when multiple binaries of same name on path?

I have multiple binaries of the same name in various directories listed in the PATH variable. I have multiple binaries because I use different versions of the same software for different things. I ...
6
votes
4answers
304 views

How would you separate fields with multiple spaces and store them in an array?

In my file mytxt: field1 field2 ------ ------- this are numbers 12345 this letters abc def ghi Let's say I want to store the first field ...
1
vote
1answer
45 views

Manipulating a continuously changing command output stream

I'm trying to change the output position of a file transfer made with rsync, as shown below: rsync -zvh --progress ubuntu-19.10-desktop-amd64.iso /home/lnxusr/Downloads/ From this: ubuntu-19.10-...
1
vote
0answers
22 views

How to quickly switch screen and sound output in Ubuntu 18.04 from commandline?

I use TV connected by HDMI cable to my laptop. I want to be able to quickly perform following operations: activate TV as main display and switch off the laptop screen, switch to the HDMI sound from ...
-1
votes
0answers
36 views

bash script to check file count and list them [closed]

here in my current directory there are lots of files with different name and I want to check particular file like (ERZAB0712190912.txt) ls -lrt ERddmmyy.txt and count this list please provide ...
3
votes
1answer
139 views

Bash script if condition not working when called from Jenkins Pipeline

The below is my Jenkins Pipeline stage stage ('Import') { steps { sshagent([sshCredentials]) { sh ''' #!/bin/bash ...
5
votes
1answer
149 views

Where are files saved when created in a WSL terminal window?

I recently installed Ubuntu in WSL on my Windows 10 system following the steps at https://www.windowscentral.com/how-install-bash-shell-command-line-windows-10. I created files in a Terminal window ...
0
votes
1answer
21 views

How to search or append a word in text file using gedit and terminal commands only

I have to calculate the time consumed in search and append operation in gedit text editor. I know that I can calculate time in any command operation by using prefix time in that command like time ls ...
0
votes
1answer
51 views

How can I execute a script that needs sudo permission in the background? [duplicate]

Since my Asus VivoBook keyboard shortcut to change de keyboard lightning level is not working, I made a bash script and configured it to be activated when I press a combination of keys. This is my ...
0
votes
0answers
28 views

Error Found when loading /home/[username]/.profile

the error message continuous when trying to load /home/username/.profile and says : tput:No value for $TERM and no -T specified
0
votes
1answer
42 views

'sudo nping -xxxx' command from script. how to disable the password request from sudo

I am using the nping tool to run tests on several networks. I also wrote some scripts to automate the parameters of such tests. I also need to avoid sudo to ask the password every time a new instance ...
0
votes
1answer
57 views

Package to install bash script that needs root/sudo access

Is there a way to create a Snap/Snapcraft or Debian package that could install a bash script as an "application" with an icon in the Dock--specifically, one that needs to be run as root in order to ...
0
votes
2answers
116 views

How do I prevent a bash script from exiting UNLESS the user enters “x”? [closed]

I am very new to ubuntu and my assignment is to create a complicated bash menu/echo script (done!) - BUT "Only exit when the user enters x". I included an exit option when "x" is selected but the ...
0
votes
0answers
55 views

Why is my command based menu system breaking? [closed]

I'm trying to create a menu with various text processing commands. My code was working at one point but something is breaking. #!/bin/bash PS3='Please enter your choice: ' options=("Search a file ...
0
votes
1answer
34 views

Permission Denied: System calls in c

I am attempting to code and execute bash scripts using C lang. Purpose is for a personal project I'm writing in C, and seeing if I can include bash capabilities as well. I created a simple C file ...
0
votes
1answer
38 views

Get variables from php file to bash sh script

Im building a shell script to automate some process on my work. I need to pull some variables from a php they are created like this: return [ 'db' => [ 'table_prefix' => '', ...
1
vote
1answer
21 views

Make message in syslog message if a program is opened

I have a file containing program names. If a program is opened, a syslog message should be generated. So far, I have written a script to collect the id of each program; how should I generate the ...
0
votes
1answer
42 views

Restart service from bash script

I'm trying to restart a service myservice from a service that is run as a daemon. I've created a file called myapprestart in /etc/sudoers.d/ that looks like this %myuser ALL=NOPASSWD: /bin/...
1
vote
2answers
66 views

sed command to remove a word from a string

Thanks for your valuable explanations. But it seems that I've failed to brief my actual requirement. The input string and desired output required were given below: input string: LINK:['...
1
vote
1answer
44 views

How to add new columns to CSVs with the same text in all lines

This a sample of my input file: 22/12/1999,conductivity,42,uS/cm 06/01/2000,conductivity,22,uS/cm 26/01/2000,conductivity,26,uS/cm 09/02/2000,conductivity,32,uS/cm 23/02/2000,conductivity,33,uS/cm I ...
4
votes
0answers
52 views

What is the difference between #!/bin/bash and #!/usr/bin/env bash? [duplicate]

In tutorials for Ubuntu scripting I see as first line of a script either #!/bin/bash or #!/usr/bin/env bash. What is the difference between those?
4
votes
2answers
84 views

How to remove all files without deleting the directory? [duplicate]

I have a sample dir as follows: /path/to/dir/ - f1.txt - f2.txt - f3.txt I want to clear or remove all the files under /path/to/dir without actually deleting the directory /path/to/dir itself. How ...
-5
votes
0answers
91 views

What are the similarities and differences between “|”, “>”, and “`” and between piping and process substitution? [duplicate]

I know they are a very useful command line and also know a little bit how to use those commands. There are three ways to represent the information on the command line such as using: | > ` I am ...
1
vote
1answer
49 views

Concatenate files from 011 to 019

I have the following files #+BEGIN_SRC shell ls | head -15 #+END_SRC #+RESULTS: | 00.contents.org | | 00.preface.html | | ...
0
votes
0answers
15 views

./checkbot.sh: /bin/bash^M: bad interpreter: No such file or directory [duplicate]

-bash: ./checkbot.sh: /bin/bash^M: bad interpreter: No such file or directory checkbot.sh reads: #!/bin/bash if ! screen -ls | grep -q "Pikku"; then exec /home/pikku/bot.sh fi bot.sh reads: #!/...
0
votes
1answer
25 views

Cannot schedule a bash script with crontab

I am going crazy as not understanding what I am doing wrong. I wrote this bash script to run a php script with nohup. It looks like this: #!/bin/bash nohup /usr/bin/php /opt/bitnami/nginx/html/...
0
votes
1answer
41 views

How to force PS1 to evaluate so I can use terminal title as a status bar?

I wanted to use the set-title function from https://askubuntu.com/a/774543/435408 to make the terminal title into a sort of status bar. That way I can see in the GUI whether my server is Running or ...
0
votes
0answers
26 views

how to see what is happening in an init.d script?

Something is going wrong in a script and I cannot find a way to view what is happening. something wrong here whether I put quotes about the "$DAEMON_OPTS" or leave them out script start-stop-...
-1
votes
1answer
45 views

sudo cat /dev or /proc

I am trying to get data output from certain directories such as /proc and /dev. I can get most data from /proc. However nothing from /dev. I understand that its main output is devices connected to the ...
18
votes
1answer
3k views

Why isn't tilde recognised as home folder in this case?

This doesn't work: $ ls "~/.wine/drive_c/tools/Family Tree v2.0" ls: cannot access '~/.wine/drive_c/tools/Family Tree v2.0': No such file or directory But this does: $ ls "/home/daniel/.wine/...
0
votes
0answers
33 views

bash function check for n times or exit on success

I have 2 functions to check on password resets coming from AD. I would like it to check for 60 seconds every 5 seconds or exit on the variable "$countdown" = 89 I'm sure it's simple but I'm getting ...
1
vote
1answer
64 views

How can I test if there are entries in the terminal command history in bash?

I'm still quite new to bash scripting and I need a very simple script that, if there is command history, displays it, and, if there isn't, informs the user that there is no command history. What I ...
0
votes
2answers
42 views

When making an alias; quatation marks, apostrophes or semicolons can prevent the command to work properly?

I have a file called .bash_aliases where I keep my first (and only one untill now) alias witch work properly, but when I tried to create a new one the terminal failed to recognize the command line, I ...