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
Tag: sh
Is it possible to get current CPU utilisation from a specific core via /sys in Linux?
I would like to write a shellscript that reads the current CPU utilisation on a per-core basis. Is it possible to read this from the /sys directory in Linux (CentOS 8)? I have found /sys/bus/cpu/drivers/processor/cpu0 which does give me a fair bit of information (like current frequency), but I’ve yet to figure out how to read CPU utilisation. In other
how to search a file only in user profile and root in linux/unix [closed]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question
How to use find, ls commands to display file names based on entries in an array?
I have an array, that contain the wildcards/filenames tha may be present in a directory. How can I display the files in a directory, whose names matches with names in the array. By the way, if possible, without using for loop. Ex: Answer The correct syntax is to use curly braces when accessing arrays: For find, it’s a bit more
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
How to trap CTRL+Z in Linux POSIX shell script; possible or not?
I am a Linux shell scripter, I would like to know if it is possible to trap signal for script sleep: That is Ctrl+z? I do it at the moment like this and would like to trap that sleep signal too. Where the print_error_and_exit function just does as its name says. Goal: I would like to ignore this signal, if
Linux SHELL script, read each row for different number of columns
I have file and for example values in it: I need to read values using the shell script from it but number of columns in each row is different!!! I know that if for example I want to read second column I will do it like this (for row number as input parameter) But as I mentioned number of columns
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/some.xml And I want to execute some.xml in all the subdirectories and get the output to a file using “>” operator I guess. What would be the proper script for this? I tried
Submit executable + input files with qsub to create multiple jobs
I have an executable that takes one input file and have been running it like so, submitting as a job to pbs using qsub: I have a script (runpp_multi.sh) to make it run on multiple files in a directory: These both work fine, but obviously there’s a problem if I submit the script that runs on multiple files with qsub:
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