Skip to content
Advertisement

Tag: shell

Bash export variables but only for current command

I want to load some environment variables from a file before running a node script, so that the script has access to them. However, I don’t want the environment variables to be set in my shell after the script is done executing. I can load the environment variables like this: However, after the command is run, all of the environment

How to print IP address from Shell Script?

Below is my command line I want to get output of IP address(10.1.2.133) alone as output. How to write command line for that? Answer If you don’t mind a solution which is not elegant, but does the job, just pipe the output of your grep command into This splits the line first by the = and then :. If the

Changing contents of a tsx file through shell script

I have a requirement to change the contents of config.tsx file that contains values like: I want to change this content using a shell script and save the file. Changed content can look like: How can I do this? Answer This should work: The -i option will edit the file in place. If you first want to try the command

How logical operators works

I tried below but it doesn’t work. Throwing some errors. Exp1 or expr2 should evaluate first & at result should be evaluated with expr3 ( &&) i tried as per suggestion, it throws error as Fyi- that date is val1 value. Answer You might see different results based on the shell or version, eg: sh vs bash vs ash. One

Can substring expansion be used in dash shell or bourne shell?

I’m converting an app to a new image, and the existing commands use substring expansion to set the artifact version like so: mvn clean versions:set -DnewVersion=”0.1.$VCSINFO.I${INFO:0:6}.M$OTHER_INFO”. I’m using a ubuntu image that defaults to /bin/sh, and I am unable to figure out how to either do something equivalent in bourne shell, or switch shells to run the command. I know

shell if statment executing even if its not true [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 2 years ago. Improve this question

Redirect logs of pods in my k8s to a file with pod name

I was trying to redirect logs of pods in a k8s into a file of their name. kubectl get pods | awk ‘{print $1}’ | tail -2 | xargs -I {} kubectl logs {} > {} This is the result. demo@demo1:~/log$ ls {} What I need is, if this is the pod details demo@demo1:~/log$ kubectl get pods NAME READY STATUS

Bash terminal error when using ‘unmask’ command [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 2 years ago. Improve this question

Advertisement