Skip to content

Tag: sh

How to iterate over two arguments in the sh linux shell

I have two sets of arguments: a = “5 7 1” and b = “dogs cats horse” They should come in pairs: 5 matches dogs, 7 matches cats and 1 matches horse They also should do this in one line: The problem is that the $a and $b can have hundreds of arguments, so writing many lines like the above

Can`t call command with variable on sh file using ssh

I have the script on centos 7 server for kill process by used id: Above script works fine when it is called from the server. But my goal calls this file using ssh from my local machine like: But I git this error: Answer you need to install lsof on the remote server. or try to add the full path

List and change directory and run command in Shell

I am coming back to shell after almost 6 years or so. I have a directory structure let’s say, MainDirectory –> subDirectory1/some.xml                      –> subDirectory2/some.xml                      …                      …                      –> subDirectoryN/…

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 excepti…