Category "bash"

Pipe a vim command after a shell command

I'm trying to make a key mapping in vim that (a) saves current file (b) performs a git action, using shell (c) quits current vim editor. I've tried the followi

how to generate core file in docker container?

using ulimit command, i set core file size. ulimit -c unlimited and I compiled c source code using gcc - g option. then a.out generated. after command ./a.o

Bash variable substitution and strings

Let's say I have two variables: a="AAA" b="BBB" I read a string from a file. This string is the following: str='$a $b' How to create a new string from the

Use a variable's value in a sed command [duplicate]

I can't seem to use a variable in a sed command, for example: sed "24s/.*/"$ct_tname"/" file1.sas > file2.sas I want $ct_tname the varia

Add shell or bash to a docker image (Distroless based on Debian GNU/Linux)

I want add shell or bash to my image to execute installation command. I have copied the /bin/bash on my VM on to my image on Dockerfile: COPY /bin/bash /bin/

How to output a multiline string in Bash?

How can I output a multipline string in Bash without using multiple echo calls like so: echo "usage: up [--level <n>| -n <levels>][--help][--versio

Postgres - testing database connection in bash

I wonder if there is an alternative to the psql command to test the connection to a postgresql database using bash. I'm setting up a Core OS cluster and have a

How to format a bash array as a JSON array

I have a bash array X=("hello world" "goodnight moon") That I want to turn into a json array ["hello world", "goodnight moon"] Is there a good way for me

Limit the number of running jobs in SLURM

I am queuing multiple jobs in SLURM. Can I limit the number of parallel running jobs in slurm? Thanks in advance!

How to check if a file is empty in Bash?

I have a file called diff.txt. I Want to check whether it is empty. I wrote a bash script something like below, but I couldn't get it work. if [ -s diff.txt ] t

Duplicate IO with file descriptors

I would like to route a file descriptor to multiple places at the same time. For instance I would like every command in my script to print stdout to /dev/ps/9

Recursive copy of a specific file type maintaining the file structure in Unix/Linux? [closed]

I need to copy all *.jar files from a directory maintaining the folder structure of the parent directories. How can I do it in UNIX/Linux term

SSH and identity file for jump server

I'm trying to log into my-server through a jump server, jump.example.com. I can successfully log into the jump server without a password request: ssh -i .ssh/id

Python print output not appearing when called from bash

Here is a minimal working example: I have a python script test.py that contains: print("Hello") and I have a bash script test.sh that calls that python functio

How to know the process id of current bash session? [duplicate]

I'm on a linux server and admin user. There're many admin users using this machine at the same time. So under current bash command line, how t

How can I convert a series of images to a PDF from the command line on linux? [closed]

I have a scanning server I wrote in cgi/bash and want to be able to convert a bunch of images (all in one folder) to a pdf from the command li

Authentication failed on tfs server

I am having a really weird issue with git bash on windows. When I am working in Visual Studio I have no problem working with my git repo stored in a tfs server

How to pass environment variables from a string to a bash command

I have a variable AAA which is in this format AAA='BBB=1 CCC=2 DDD=3' How can I use this to set environment variables BBB, CCC and DDD in a command I run (wi

Suppressing summary information in `wc -l` output

I use the command wc -l count number of lines in my text files (also i want to sort everything through a pipe), like this: wc -l $directory-path/*.txt | sort -

How can I print a newline as \n in Bash?

Basically, I want to achieve something like the inverse of echo -e. I have a variable which stores a command output, but I want to print newlines as \n.