I have a bash script from which I want to access /dev/tty, but only when it’s available. When it’s not available (in my case: when running my script in GitHub Actions) then when I try to access it I get /dev/tty: No such device or address, and I’m trying to detect that in advance to avoid the error and provide
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
How to preceed the output generated by “exec &” with a time/Date in linux bash scripts?
I have the following script file that writes files to s3 from a local file system: And the output is coming out in a specific grok pattern needed for me to parse this output as logs into Elastic Search, however the line 27 output is as follows: that upload and 0 of 0 0%… Line is created by the exec
Reading and exporting key-value pairs from a file in bash script (without caching)
I have the following project directory structure: Where run.sh looks like: Where .env is a properties file of key=value pairs like so: The setenv.sh script needs to read the key-value pairs out of .env and export/source them, so that run.sh can reference them at runtime and they will evaluate to whatever their values are in .env. The run.sh script and
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
How can I extract parameters of curl request and append them to beginning of txt file using bash
I have a bash file which is executed every 5 seconds, it goes like this: It pings to a server running in a neighbor Virtual Machine and records the curl response into the specified file “debian0_ping.txt” but the recorded response looks like this: Which is a problem because I need the pings responses to be recorded this way (the most