Skip to content

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…

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 …

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

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…