Removing created temp files in unexpected bash exit

I am creating temporary files from a bash script. I am deleting them at the end of the processing, but since the script is running for quite a long time, if I kill it or simply CTRL-C during the...

Define make variable at rule execution time

In my GNUmakefile, I would like to have a rule that uses a temporary directory. For example: out.tar: TMP := $(shell mktemp -d) echo hi $(TMP)/hi.txt tar -C $(TMP) cf [email protected] . ...

How can I create a temp file with a specific extension in bash?

I'm writing a shell script, and I need to create a temporary file with a certain extension. I've tried tempname=`basename $0` TMPPS=`mktemp /tmp/${tempname}.XXXXXX.ps` || exit...

Pipe status after command substitution

I'd like to send the result of a series of commands to a variable: variable=$(a | few | commands) However, the command substitution resets PIPESTATUS, so I can't inspect where it went wrong...

How do I prevent a C shared library to print on stdout in python?

I work with a python lib that imports a C shared library that prints on stdout. I want a clean output in order to use it with pipes or to redirect in files. The prints are done outside of python,...

Capture stdout and stderr into different variables

Is it possible to store or capture stdout and stderr in different variables, without using a temp file? Right now I do this to get stdout in out and stderr in err when running some_command, but...

Why do we need mktemp?

I do not understand the function of mktemp and what a temporary file means. Whats the difference between say touch xyz and mktemp xyz (apart from the fact that mktemp will create some file with...

Delaying wildcard expansion in bash, while quoting for special characters

I've written a bash script that needs to do something later. It's called something like this: later mv *.log /somewhere/else However, when called like this *.log is expanded at call time, and...

git archive export with submodules (git archive all / recursive)

I have a website directory versioned with git. I use submodules for required libraries like Twitter Bootstrap, colorbox and lessjs because I should not track the sourcecode but only the version of...

What is a way to read man pages in Vim without using temporary files

I want to be able to read man pages in Vim. For some reason, it seems that Vim isn't able to read the output of programs through piping. E.g (man ls) | vi doesn't seem to work, bonus points for...

shell: how to create a unique temporary file path cross-platform/portable?

How to create a unique file path in a shell cross-platform? I have looked around on most of the answers and it seems that no cross-platform/portable solution is simple enough. mktemp seems to be...

Command not working in EC2?

None of the commands are working in ec2 machine. -bash: id: command not found -bash: id: command not found -bash: id: command not found -bash: tty: command not found -bash: mktemp: command not...

Git clean/smudge filters for ansible vault secrets

I am trying to setup clean/smudge filter in git to have automatic encrypting and decrypting of files containing secrets thru ansible-vault command. Peculiarity of the ansible-vault command is that...

Create temporary file and redirect output to it in one command

I designed a custom script to grep a concatenated list of .bash_history backup files. In my script, I am creating a temporary file with mktemp and saving it to a variable temp. Next, I am...

/bin/sh: 1: apk: not found while creating docker image

I have the below Dockerfile for zookeeper and I am trying to create an image for it, but it is giving me an error. I have recently started working with Docker, and started playing with a Zookeeper...

Where is the Postgres username/password being created in this Dockerfile?

So I was following this tutorial: https://realpython.com/blog/python/django-development-with-docker-compose-and-machine/ I have everything up and running, however theres a few things going on that...

mktemp failed to create via template

I setup a new AWS server using an existing AMI. It creates an Ubuntu server: I type [email protected]:~$ mktemp I get: mktemp: failed to create file via template ‘/tmp/tmp.XXXXXXXXXX’: No...

mktemp vs. umask 066 and touch?

My bash shell requires a temp file. Suppose filename conflict is not an issue, can I say mktemp is not as good as manually touch a temp file after umask 066? My assumption is: mktemp is a system...

standard_init_linux.go:178: exec user process caused "exec format error"

docker started throwing this error: standard_init_linux.go:178: exec user process caused "exec format error" whenever I run a specific docker container with CMD or ENTRYPOINT, with no regard to...

How to install deb dependencies without installing the package?

I have a Debianized project with a debian/control file. I know how to use the mk-build-deps script from the devscripts package to install the build dependencies for this project; i.e., the...

Failure on cross compiling busybox

I'm trying to cross compile busy box V 1.27.2 for my embedded Linux device. I set share library build and cross compiler prefix and Sysroot to my compiler destinations. Compiler after trying to...

"Invalid numeric literal" error from jq trying to modify JSON with variable

I am wanting to pipe values into a bash script that will change values in a json file using jq. I've been working on this for a while now and I can't get past the first set of errors. Here is my...

`npm install` results in `cb() never called!` when running in Docker

I have a project with rather small package.json file: { "name": "chilldev-web", "version": "2.1.0-SNAPSHOT", "description": "Client-side build tool for a project.", "license":...

Using "go get" to download binaries without adding them to go.mod

I'm using Go modules in my project and in my build system (e.g. Travis CI) I'm downloading a command-line utility (written in Go) with go get to assist with my build process, e.g.: go get...

Using GNU parallel command with gfind to gain in runtime for gupdatedb tool

I make follow to the previous post combine parallel and gfind I would like to build the gupdatedb database, containing all from main root / excepted the PRUNEPATHSlisted more below. I am working...

Yum privilege escalation

I found this piece of code while doing some ctf on tryhackme. And I don't understand it. Can somebody explain me what exactly it does? TF=$(mktemp -d) cat...

Why does GNU tar --format=pax produce ustar archives?

I'm using GNU tar (v1.29) to create an archive and xxd to inspect it like this: ( cd "$(mktemp -d)" touch [email protected] 1.txt 2.txt 3.txt tar \ --format=pax \ --numeric-owner \ ...

Efficiently counting tokens column-wise in Bash/Awk/Perl

I have the following output from a pipeline. Lorem dolor sit amet consectetur Lorem ipsum dolor sit , Lorem dolor sit amet , Lorem dolor ipsum sit ! Edit The number of columns is specified by...

can push/pull from terminal not from VS Code, error: c:\\ ...\askpass.sh line 3: C:\...Code.exe: command not found; fatal: Authentication failed for

As title says I have a private git repo on my local network and can push/pull no problem from terminal outside VS Code but when I try from the integrated terminal (PowerShell) I get this...

failed to solve: rpc error: code = Unknown desc = executor failed running

Trying to install docker image using dockerfile on top of Debian 10.3 and when run docker-compose up --build, I'm getting this issue: > [mariadb:10.3.24 13/18] RUN set -ex; export...