scripts

Bash script doesn't work when used with keyboard shortcut, but works in the console

Bash script doesn't work when used with keyboard shortcut, but works in the console With the help of AI I made a script, which toggles between the two audio devices chosen by me. Since the name of the device changes on each system reboot, the script finds the devices by their property from pactl: device.product.name …

Total answers: 1

Recurring movement of complete files

Recurring movement of complete files I would like to address a query that may have been previously discussed or addressed indirectly through other inquiries. I am in need of a solution for recurrently moving files with a specific file extension from one folder to another. However, due to the automated extraction process, it is imperative …

Total answers: 1

Is there a way to use tee with the whole script from INSIDE the script?

Is there a way to use tee with the whole script from INSIDE the script? I’m making a script to update the system (Ubuntu 22.04), updating all packages in apt, flatpak and snap with one order (like sudo ./update.sh) and, in case something goes wrong, I want to save the output in a file. I …

Total answers: 2

How to replace a file path with whitespace using sed?

How to replace a file path with whitespace using sed? I have many different files with a string in them. I need to replace this string with a path, although the path contains whitespace. So far, I have this: for a in files_[a-z][a-z]_all.conf ; do fileWithPath="~/Downloads/files_config_linux/auth-user-pass files_userpass.txt" otherOne="auth-user-pass mullvad_userpass.txt" sed -i ‘s|’$otherOne’|’$fileWithPath’|g’ $a done But …

Total answers: 2

Download and Remove the files from SFTP server

Download and Remove the files from SFTP server I am using this to download the file from remote server but could you guide how can I use one command to first download and then remove the file from server. sshpass -p password123 sftp User@sft.domain.co.uk:/Complete2/Database.bak /home/user/.docker/appdata/mssql/backup/Database.bak Thank you Asked By: mouzzampk2014 || Source sftp usually accepts …

Total answers: 1

Removing spaces between words in a text file using a bash script

Removing spaces between words in a text file using a bash script I am using a bash script that parses data from a bunch of different text files and generates a .dts file. The .dts file contains spaces between each column title and I need to remove them as it makes a plotting tool I …

Total answers: 2

File removal on power off

File removal on power off I’m using Ubuntu 22.04LTS. I would like to create a folder "temp" where during my session I save the files that are, as the name suggest, temporary. How can I define a scritp that at shutdown automatically deletes the contents of this folder? Ex: I download few documents that I …

Total answers: 3

Script to notify via email when low on disk space

Script to notify via email when low on disk space I found the below mentioned script on the internet, which notifies via email when server gets low on storage or as per defined. I run it every 5 minutes, if i am low on storage it keeps notifying me with email after 5 minutes. What …

Total answers: 1

sed mongodb connection string copying multiple times in env variable through github action

sed mongodb connection string copying multiple times in env variable through github action this is command which i run in github action its copying into .env.production file sed -i "s#DB_URI=.*$#DB_URI=mongodb+srv://xxxxxx:xxxxxxxx@db-mongodb-sfo3-api-discovery-f417ebf8.mongo.xxxxxxxxx.com/webapp_test?tls=true&authSource=admin&replicaSet=db-mongodb-sfo3-api-discovery#" And this is error/job build status which shows multiples copying DB_URI=***db-mongodb-sfo3-api-discovery-f417ebf8.mongo.xxxxxxx.com/webapp_test?tls=trueDB_URI=***db-mongodb-sfo3-api-discovery-f417ebf8.mongo.xxxxxx.com/webapp?tls=true&authSource=admin&replicaSet=db-mongodb-sfo3-api-discoveryauthSource=adminDB_URI=***db-mongodb-sfo3-api-discovery-f417ebf8.mongo.xxxxxx.com/webapp?tls=true&authSource=admin&replicaSet=db-mongodb-sfo3-api-discoveryreplicaSet=db-mongodb-sfo3-api-discovery Plse let me how i can solve this Asked By: DevOPs || Source Escape …

Total answers: 1

Setting DEBIAN_FRONTEND remotely

Setting DEBIAN_FRONTEND remotely Is there any way to set DEBIAN_FRONTEND=noninteractive when executing a script remotely via SSH? Doing so I get this error: sudo: sorry, you are not allowed to set the following environment variables: DEBIAN_FRONTEND The reason I want to set DEBIAN_FRONTEND=noninteractive at exactly this place is because sometimes apt-get dist-upgrade shows a mask …

Total answers: 2

Why does my powershell script run with "pwsh" but doesn't with "sudo pwsh"?

Why does my powershell script run with "pwsh" but doesn't with "sudo pwsh"? I’m still somewhat new to Ubuntu / Linux so please bear with me if I’m not using correct terminology. I’m on Ubuntu 20.04 but I use Putty to perform everything via the terminal. I’m using a collection of shell scripts (.sh files) …

Total answers: 1

How to identify the input that caused a program to segfault?

How to identify the input that caused a program to segfault? I have scripts that run programs (that I did not author) and some are getting segfaults on a few inputs. I do these things in large batches that run for up to a week, and would like to know which input(s) are triggering the …

Total answers: 1

How to use invert match regex in sed? like grep

How to use invert match regex in sed? like grep How can I use invert match regex like grep -v ? I want invernt sed ‘/[Ss][0-9]*[Ee][0-9]*/d’ ${Src} like grep -ev ‘[Ss][0-9]*[Ee][0-9]*’ ${Src} Asked By: fsgdfgdfgd || Source I assume you mean grep -ve ‘[Ss][0-9]*[Ee][0-9]*’ (since grep -ev ‘[Ss][0-9]*[Ee][0-9]*’ would try to match pattern v in …

Total answers: 1

Find duplicate case insensitive filenames in all folders and sub-folders

Find duplicate case insensitive filenames in all folders and sub-folders I have about 250,000 files in several folders with sub-folders. Looking for a solution how to find duplicate filenames in all folders and their sub-folders. My OS is Ubuntu 22.04, using bash. I prefer a bash command/script solution. However, suggestions about tools similar to fdupes …

Total answers: 2

Dolphin context menu exec command, cp will duplicate selected folder if already copied

Dolphin context menu exec command, cp will duplicate selected folder if already copied So I’m trying to automate some tasks and I’m making some dolphin ServiceMenus. Exec=for file in %f; do new_path=$(echo "$file" | sed "s|^/home/$(whoami)||"); mkdir -p ~/Dropbox/.Home"$(dirname "$new_path")" && cp -pur "$file" ~/Dropbox/.Home"$new_path"; done The above line will work perfectly fine for what …

Total answers: 1

Timer program that plays 4 sounds one after another for 30 seconds each

Timer program that plays 4 sounds one after another for 30 seconds each Could someone help me. I need a bash script to play a short sound file, wait for 30 seconds, play another sound file, wait for another 30 seconds. (I will use it as a reminder to spend 30 seconds on each quadrant …

Total answers: 2

Should we put file names in Bash in Quotes or Double quotes? What is the standard?

Should we put file names in Bash in Quotes or Double quotes? What is the standard? Should we put file names in Bash in Quotes or Double quotes? What is the standard? SRC=file or SRC=’file’ or SRC="file" ? Asked By: fsgdfgdfgd || Source There is no "standard" according to the Bash Reference Manual. Variables (Shell …

Total answers: 4

ask user to enter input such as their age and save it to a variable

ask user to enter input such as their age and save it to a variable Im trying to make a simple bash script work as a beginner exercise where im asking a user to enter their age and the script should echo depending on their input "You are old" or "you are young" if they …

Total answers: 2