Skip to content
Advertisement

Tag: bash

remove comma in jsonpath template using bash

I have a JSON path template query. i’m redirecting it to csv. getting comma in a message from above output , i want to replace the comma with space for the second column(message) in the bash script. Anyone has any thoughts on how can achieve this. Expected result Answer Assuming you can change the field delimiter to a character known

how to write Bash script for getting Public ip address in a way that when one command failed then it have to execute another command

i want to write a bash script in a way that if one command gets failed then it will have to execute another command. For example:- “curl www.ifconfig.me” if this command gets failed then another command “curl http://icanhazip.com” to get execute and should show the output. Answer If you want the HTTP code, try this: Then: After that, you could

Linux, how to parsing for pci express NVMe?

I’m working on bash script getting the pci nvme address for hot reset. I want to parsing for pci express nvme ADDRESS (i.e /sys/devices/pci0000:00/0000:00:01.2/0000:01:00.2/0000:02:00.0/0000:03:00.0/nvme/nvme0 how can i do this? I want to parse the address value before nvme. Answer You can use cut with / as the delimiter.

Delete newlines from all elements of a array in shell

I try to solve a problem in shell. Im trying to find a way to delete all newlines from each element of an array. I tried to do this with a for loop. The Strings look like this (always three numbers, separated with dots) “14.1.3n” and I need to get rid of the newline at the end. This is what

Current path is not showing in terminal for new CentOS user [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 extract the directory from full file path

I have the following script which prints various file stats, which was kindly supplied by another user (choroba) (link). Is there a way that this can be amended to report just the directory name of each file and not the full file path with the file name? I have tried changing filepath with dirname and I get a series of

Advertisement