Category "shell"

Packer unable to read shell script while using Docker plugin

I am trying to create a docker image using Packer. However, when I am trying to use the shell provisioner it is unable to find the shell script. learn-packer.do

Update global variable from while loop

Having trouble updating my global variable in this shell script. I have read that the variables inside the loops run on a sub shell. Can someone clarify how thi

Count character difference between two files in bash

What would be the best way to count the number of characters that are different between strings in two files. I know how to do this in Python but I need a bash

Bash program that returns 1 on input and 0 otherwise

Is there a standard linux terminal program that when given text input (in standard in) returns a 1 and 0 if no text is provided? (The reverse logic would also b

How to error handling curl and mysql in python subprocess.run()

I have python script which uses subprocess.run() getting dump file by curl and input dump file by mysql cmd = "curl {0}/{1} -o /tmp/{2}".format(dir_name,file_na

How to write the regex to capture alphanumeric value between square brackets?

Please help in writing the regular expression for below line in bash. There are muliple lines like this in my file, and I want to only capture the below values

Running shell command that has nested quotes via ssh

I have this following shell command: ssh user@host "df | grep /dev/ | \ awk 'BEGIN{print "DISK", "%USAGE", "STATUS"} {split($5, a, "%"); \ var="GREEN"; print $

How do you use mktemp to create directory in Makefile?

This is a Makefile piece of code of how someone may use mktemp in a Makefile TEST=$(shell mktemp -d) mktemp: echo $(TEST) touch $(TEST)/test.txt ls

Why does "(echo <Payload> && cat) | nc <link> <port>" creates a persistent connection?

I began with playing ctfs challenges, and I encountered a problem where I needed to send an exploit into a binary and then interact with the spawned shell. I fo

Append lines separated by comma while preserving the existing new line

Bash script used: #!/bin/bash set -xv IS=$'\n' list=$(cat exlist_sample | xargs -n1) for i in $list; do echo "$i" | rev > slist echo "$i" >> z

How to generate date in this format (2022-04-29T06:07:28.158Z) in linux

Looking for solution to generate date in the below format: 2022-04-29T06:07:28.158Z Have to use in bash script.

edit the ID column to add chr to a number

I have a vcf file. It looks like this: It has a vcf header followed by genotype information. I want to add chr to third column. Like now it looks like: 21 98257

how to perform string operation in an input string and get the desired output

I have to write a shell script to accept the product order details as string input and display the total order amount and number of order under each category.

Watch changes in a file and restart python script

I want to restart a python script(restart.py) whenever some edits a file (test.txt) =====restart.py==== from time import sleep for i in range (1000): print

git checkout shell alias not working as expected

I'm using zsh and I added "gc" as an alias for "git checkout" as below in the .zshrc file. alias gc="git checkout " When I execute git checkout dev, it works fi

How to execute script as bash using "at"?

It was a pain to google solutions for my problem since it is using application "at" :) So the thing is, I am trying to run long runnng operation (I know that I

When using python to run adb shell command, how can i kill a running program in adb shell?

For Android device, if i enter adb shell in iTerm and then run some program to continuously output data(like getevent, logcat), i can kill these programs by CTR

Bash - Remove leading zero for numbers with double digits

I have a variable in bash number which contains values 01, 02, 03, 04, 05, 06, 07, 08, 09, 010, 011, 012. I would like to remove the leading zeros before 010,

Trap and exit big shell script with background processes

I have 2 shell scripts that contain ffmpeg commands (command1.sh and command2.sh). command2.sh has like 500 ffmpeg commands that trigger one after another with

How can I generate a 2D matrix of natural numbers wth zero in ascending order in shell script or another programming language?

I need to generate matrices of natural numbers in ascending order with zero (0), but they are very large ones and it will be hard to write them by hand. What I