Skip to content
Advertisement

Tag: shell

Provide windows avilable cores

I use the following in my script to find how many available cores I can use. This is for Linux: This is for Mac (darwin): How should it be in Windows? Answer You can use one of those commands: (here you have two physical processors) Or as suggested in comments: In Makefile the record should be something like: P.S. And

How to grep within a loop to exclude?

I have a NPM_RESERVED_SCOPE that contains a comma-separated list of forbidden scope. I have a NPM_ALLOWED_DEV_DEPENDENCIES_PACKAGES that contains a comma-separated list of exception. I want this script to passe if the devDependencies does not contains any of the NPM_RESERVED_SCOPES, except the list of exception. This is the file package.json How can I do? Answer Convert the lists into extended patterns

Use environment vars with head

I need to use some vars in a script where I use tail and head, my script works when I type it in the terminal but when it is in a .sh file I get this error from the head command: The error comes from this pipe of my script: I tried using variables in another script where only declaring

Unable to substitute a custom variable in Authorization header value in curl

I am trying to use $timestamp and generate hash. I see $timestamp value is not getting assigned and it’s always same. My request:– Output[Request Authorization headers] 20180701T12:33:56+0000 is the correct value which i want to get substituted in ‘$(echo -n $timestamp’ but it’s not happening. $timestamp is not changing at all after the curl command execution. To Test:– I initially

Replace string pattern with a string in linux file [closed]

Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 years ago. Improve this question I am a newbie to Linux. Need to replace With using sed or some alternative. Answer Command that given desired

How to replace ‘-u username -p password’ with new value in linux shell?

old value: 10.125.11.5:27017 -u username -p password new value: 10.125.19.6:27017 I want to replace all the old value in *.py files (current directory folder and subdirectory) using shell,how to do? seems sed or grep can not work with’-u’ or ‘-p’. Answer Suppose you have an inputfile with this content: After executing this: You get this input file: That should help

sed for print two different word alernatively

I have a requirement to print two different words in alternative white spaces in the file. For example, The above scenario, I want print ab and /ab alternatively like below: *I want this one by one in a line by line format(Not horizontal format).*I know sed ‘s|^[[:blank:]]*$|</ab>|’ this command is almost near to my case. But I don’t know how

How to configure the find command to run in a Linux shell script?

I am trying to run the following find command in a Linux shell script. When I run the command in the terminal, it successfully finds all the files with the extension .mp4 from the specified folder, and copies them to a temp folder. However, when I run it in my file_mover.sh Code: Output: I think I’m missing syntax somewhere in

Advertisement