Unix - "xargs" - output "in the middle" (not at the end!)

example use of xargs application in Unix can be something like this: ls | xargs echo which is the same as (let's say I have someFile and someDir/ in the working directory): echo someFile...

bash scan millions of files and scan for a value quickly

I have millions of files in a folder (nested). I need to scan a value from those files and print lines containing this value (say LINE_TXT). Earlier I used to sed each file but it used to take...

How to find/replace and increment a matched number with sed/awk?

Straight to the point, I'm wondering how to use grep/find/sed/awk to match a certain string (that ends with a number) and increment that number by 1. The closest I've come is to concatenate a 1 to...

How to exit a shell script if targeted file doesn't exist?

Given the script below, I would like to avoid the execution of the pipeline if a file does not exist. How may I exit the script straight away if the text file is not found? ls */*.txt | grep ab1...

Changing console_script entry point interpreter for packaging

I'm packaging some python packages using a well known third party packaging system, and I'm encountering an issue with the way entry points are created. When I install an entry point on my...

Pipes in a Git alias?

I work on feature branches that have annoying big names, so I often end up grepping my current branch name when I need to push up to the feature branch from my local feature branch, like so: git...

Final arguments for xargs

I want to do something similar to this: find . -type f | xargs cp dest_dir But xargs will use dest_dir as initial argument, not as final argument. I would like to know: Is it possible to...

Using xargs with Special characters

I have the following problem. Got a file which includes certain paths/files of a FS. These for some reason do include the whole range of special characters, like space, single/double quotes, even...

Cygwin can't find files in shell script

I am running a shell script in Cygwin, and the files in the shell script aren't showing up, even though they are definitely in the same directory as the shell script. Cygwin command: $ bash...

how to delete a file with quote in file name

When I do ls in my directory, get bunch of these: data.log".2015-01-22" data.log".2015-01-23" However when I do this: rm: cannot remove `data.log.2015-01-22': No such file or directory If I...

How to sort and get unique values from an array in bash?

Im new to bash scripting... Im trying to sort and store unique values from an array into another array. eg: list=('a','b','b','b','c','c'); I need, unique_sorted_list=('b','c','a') I tried a...

how to pass command-line arguments to a program run with the open command?

Is there a way to pass arguments to a program being run via: open -a /Applications/Utilities/Terminal.app ~/my_executable I have tried: open -a /Applications/Utilities/Terminal.app...

Install latest python version with pyenv

With ruby-install, to install the latest stable ruby version, one needs only ruby-install ruby. However, with pyenv one seems to need to do something ridiculous like pyenv install $(pyenv install...

Is there a "one-liner" for submitting many jobs to SLURM (similar to LSF)?

Can I submit "one-liners" to SLURM? Using bsub from LSF and the standard Linux utility xargs, I can easily submit a separate job for uncompressing all of the files in a directory: ls *.gz | sed...

Is there an elegant way to split a file by chapter using ffmpeg?

In this page, Albert Armea share a code to split videos by chapter using ffmpeg. The code is straight forward, but not quite good-looking. ffmpeg -i "$SOURCE.$EXT" 2>&1 | grep Chapter | sed -E "s/...

bzgrep not printing the file name

find . -name '{fileNamePattern}*.bz2' | xargs -n 1 -P 3 bzgrep -H "{patternToSearch}" I am using the command above to find out a .bz2 file from set of files that have a pattern that I am looking...

ioredis delete all keys by pattern

I'm using ioredis with express (nodejs) I know that there is a way to delete keys by pattern like this: redis-cli KEYS "sample_pattern:*" | xargs redis-cli DEL However, is there a way to do that...

How to set permissions recursively, 700 for folders and 600 for files, without using find

I'm trying to figure out a way to set permissions recursively 700 for dirs and subdirs on a specific path and 600 for files. I would use these commands: find /path -type d -print0 | xargs -0 chmod...

Rails logs do not show anything in terminal for Puma when I try to hit the URL: localhost:3000

When I do rails s, it successfully starts my server, and serves the page through the URL http://localhost:3000, but the problem is: it doesn't show any changes when I access anything from this...

How to use split function in perl to do the work of awk

I am writing a script in perl and I want to avoid using external commands as awk, tr , etc as much as possible. This is the command I am running from inside the script , using backticks: my @arr =...

Execute command in all immediate subdirectories

I'm trying to add a shell function (zsh) mexec to execute the same command in all immediate subdirectories e.g. with the following structure ~ -- folder1 -- folder2 mexec pwd would show for...

How do I extract multiple values from kubectl with jsonpath

I've found jsonpath examples for testing multiple values but not extracting multiple values. I want to get image and name from kubectl get pods. this gets me name kubectl get pods...

How do I list the roles associated with a gcp service account?

In the google cloud gui console I went to "IAM & admin" > "Service accounts" and created a service account named "my-service-account" with the viewer role. I then ran this command: gcloud iam...

How to delete all merged local branches in Git with PowerShell

How can I iterate through my branches, filter out merged branches and delete them using Git for Windows in Powershell? I have already attempted some research, but every answer I have found...

Stale rabbitmq data queue files eating up disk

The disk on one of our test deploy servers went full. It normally runs several docker containers, several which communicate using rabbitmq (also running as a container, image...

How do I delete properly node_modules from Mac?

My Mac is running low on space. The first place I always look is the node_modules directory as I run many projects at a time - as I'm sure we all do! I am not sure whether I should just clean all...

Rebuild android code with error “SSL error when connecting to the Jack server. Try 'jack-diagnose”

System: ubuntu 18.04 environment:VirtualBox The first time I compiled the AOSP source code on Ubuntu 18.04, it passed, and the second time I compiled it failed. Here is an error message. [ 10%...

Gitlab diff between Merge Request Target branch and Source Branch in pipeline

My use involves finding a diff between Merge Request and Master or Release branch (whichever branch I want to diff against) the MR will have CI_MERGE_REQUEST_TARGET_BRANCH set. CHANGED_DIRS=$(git...

CrashLoopBackOff on postgresql bitnami helm chart

I know there have been already a lot of questions about this, and I read already most of them, but my problem does not seem to fit them. I am running a postgresql from bitnami using a helm chart...