Category "bash"

Bash- Converting a variable to human readable format (KB, MB, GB)

In my bash script, I run through a list of directories and read in the size of each directory to a variable using the du command. I also keep a running total of

command blkid don't show my partitions UUID

I'm using Ubuntu. command blkid or blk /dev/sda2 in LPIC-1 module 104.3 (mounting and unmounting). but these commands don't show me the expected results. blkid

How to use multiple CPUs with Python on a HPC?

I'm working on a data analysis project in Python and I'm using a HPC cluster to process my data. I'm having a hard time getting my program to use multiple CPUs

How to create an alias in a shell to go to parent directories

I'm wondering how to create an alias with endless arguments for going parent directories without alias name! Currently I have written this function to achieve

How to create an alias in a shell to go to parent directories

I'm wondering how to create an alias with endless arguments for going parent directories without alias name! Currently I have written this function to achieve

Bash : Find and Remove duplicate files from different folders

I have two folders with some common files, I want to delete duplicate files from xyz folder. folder1: /abc/file1.csv /abc/file2.csv /abc/file3.csv /abc/fil

Confirming Shell Script Input

I'm writing a script to preform a repetitive task that only changes basic values and locations such as user name. I've written up code that prompts for a usern

Copy Files from Windows to Windows Subsystem for Linux (WSL) [closed]

I have enabled developer mode and installed Bash on Ubuntu on Windows. My home directory can be found under %localappdata%\Lxss\home\<ubun

saving output of nettop to file ( mac ) [closed]

I'm trying to save the output of nettop from my terminal to a text file ( maybe .csv ) what I want to do is be able to isolate the different v

How to detect and remove indentation of a piped text

I'm looking for a way to remove the indentation of a piped text. Below is a solution using cut -c 9- which assumes the indentation is 8 character wide. I'm loo

How to declare a var in bash without it replacing a var in a different file

I have 2 files file1 and file2. Inside file1 I declare a var, x=1. In file2 I make a var x=2. If I run file one then file two, and then in the shell echo x, I g

substitute characters in a string in all possible combinations

Character substitution in all possible combinations I have string as follows, XGXXGXXGGXXGXXGX I would like to iteratively substitute X's for either one, two,

Replace tags in text file using key-value pairs from JSON file

I am trying to write a shell script that can read a json string, decode it to an array and foreach through the array and use the key/value for replacing strings

define environment variable in databricks init script

I want to define an environment variable in Databricks init script and then read it in Pyspark notebook. I wrote this: dbutils.fs.put("/databricks/scripts/i

Convert mp3 -> Video with static image ( ffmpeg/libav & BASH )

Some years ago I used the following bash script to get a video out of mp3's and one image (so the image in the video was freezed over the length of the mp3), wh

Linux flock, how to "just" lock a file?

In Bash, I'm trying to make a function getLock to be used with different lock names. function getLock { getLock_FILE="${1}" getLock_OP="${2}" case

Trying to loop through lines on stdin

I would like to make a short script that will eventually run a quiz. I'm trying to read stdin, which contains a new-line delimited list of words, for example: v

C# execute a terminal command in linux

I want my c# application (which I execute on a raspberry pi) to run a bash script whenever it starts.. basically : the script is located in /etc/init.d and is n

Multiplying strings in bash script

I know that if I do print ("f" + 2 * "o") in python the output will be foo. But how do I do the same thing in a bash script?

Why does Bash trap not capture the exit status for an undefined variable?

I need to capture error conditions in a Bash script using a trap. For this reason I've both set -e AND set -u in my script. However I've noticed that the trap